UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'yQTFiiMzdZ4QlhhmI0HSRhQFGqgRO5+Ixz0HLR8Y+K4='
WHERE
key_id = '6974fb3087e3952ba7b42ab44c1054b8e8b8df9932addb780840265f482a019a'
AND (
token = 'yQTFiiMzdZ4QlhhmI0HSRhQFGqgRO5+Ixz0HLR8Y+K4='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)