UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'Lh8w3KJgng2ApNKj7YQv95AurI8OsS6AIESRakzEUZ8='
WHERE
key_id = '840c3ece04a5c808e911c07787d966a07bad5a4543f8a857569573175728178a'
AND (
token = 'Lh8w3KJgng2ApNKj7YQv95AurI8OsS6AIESRakzEUZ8='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)