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