UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'Z64HMxiGyZqIER1v+l6vgczTGpGfBkDS0a1dKwxPwH0='
WHERE
key_id = 'c2fd5c079953768afe9025c9770e8929671c2d592051efe546ac2db776e2fcee'
AND (
token = 'Z64HMxiGyZqIER1v+l6vgczTGpGfBkDS0a1dKwxPwH0='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)