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