UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = '7+RMmawrGoPEg9sOBQYmos3IhIGZuu07O+ImTmZLAoE='
WHERE
key_id = 'a851e3b91737117fea2e91a8bb449e05142790fbf7095e6c8146f3b9517ce8f3'
AND (
token = '7+RMmawrGoPEg9sOBQYmos3IhIGZuu07O+ImTmZLAoE='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)