UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'qYHVIrKUpXJvpwWn0qeICwU3V9J5stY6Ug7U+HUWfyI='
WHERE
key_id = 'e9580b282e1228681569124dfefe6e10342571e2f7b7b420af567abf77cf8f10'
AND (
token = 'qYHVIrKUpXJvpwWn0qeICwU3V9J5stY6Ug7U+HUWfyI='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)