UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'Q8x3tUsJQXdCdKPUaI7vu9L6OAxil5DFh7zeRYtyemA='
WHERE
key_id = 'fd77415c7bfeee0c80872b79ea4ac93baa497a26a517a4655c655162ae320b4d'
AND (
token = 'Q8x3tUsJQXdCdKPUaI7vu9L6OAxil5DFh7zeRYtyemA='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)