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