UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'n97mSTnt+fFdrNtPEi2NsGou0VDhxSeYbiSYmFOLRX4='
WHERE
key_id = 'f2013054570f56348de968d5639ed82122c65336a8366a58efb5fea3184dc54a'
AND (
token = 'n97mSTnt+fFdrNtPEi2NsGou0VDhxSeYbiSYmFOLRX4='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)