UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'JN4pi3HJ0Rq+9AUX0Z5zSYeWcEzrIlndYC95iq3faRU='
WHERE
key_id = 'd7b9e1283700dc3e8199a9a3b8a116088a7a671aa13da7eadbd3677a747837ac'
AND (
token = 'JN4pi3HJ0Rq+9AUX0Z5zSYeWcEzrIlndYC95iq3faRU='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)