UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = '0MefwNWzpYBSgyothiNuvvYdz2WuHomgWY0sm1M0v7w='
WHERE
key_id = '1a9c4b9446bb768c7b03997bc7818b7cc20b322f55ed981573e24c971041027e'
AND (
token = '0MefwNWzpYBSgyothiNuvvYdz2WuHomgWY0sm1M0v7w='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)