UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'a5KP3Oc7ZTEdc0HV9X+prW5x67509eCb0iP4IsT3I+4='
WHERE
key_id = 'ec1de594ce03305e26414d06bdd648d781618c28e607f54ff9404396e0eb489a'
AND (
token = 'a5KP3Oc7ZTEdc0HV9X+prW5x67509eCb0iP4IsT3I+4='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)