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