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