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