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