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