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