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