UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'Q9nPgFrna1G0Vd2FA522YSaQe4hRIsBztFyH7uHf3F4='
WHERE
key_id = '8f9ce63467807750b0d6882f135a6f85381e1208d6143404f299211c10d48bb3'
AND (
token = 'Q9nPgFrna1G0Vd2FA522YSaQe4hRIsBztFyH7uHf3F4='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)