UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'Y77w8olHAOGIqIWNxDQyETOak/6wGxjHlea6pdSN7V4='
WHERE
key_id = '51ef43af92af9c60f74dbc47fff3bc720bce257b31fd99827bd7a2332e2c9a03'
AND (
token = 'Y77w8olHAOGIqIWNxDQyETOak/6wGxjHlea6pdSN7V4='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)