UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'qJ0eArTBNRZHFNiGc/kMV16hVU4t5Xg5DZ+hDoAwuCE=' 
WHERE 
  key_id = '794da5c26c7f4aa317207867a85df74423440b2ee79eda06311721b27b17f34d' 
  AND (
    token = 'qJ0eArTBNRZHFNiGc/kMV16hVU4t5Xg5DZ+hDoAwuCE=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00053