UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'ChY7qZHq6jFxJnC+f/ieBmrh/o+3l475jRiv04P2nh8='
WHERE
key_id = 'c13716c09c5c96ccf6affd28bff73098fca9e54e4492975b1440f71e3489a44b'
AND (
token = 'ChY7qZHq6jFxJnC+f/ieBmrh/o+3l475jRiv04P2nh8='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)