UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'hZ+NLdjIUmBVq3VCzDS9fcYguN9qEr/5QQbdr+Rge0o=' 
WHERE 
  key_id = 'd0160026dc858b4676efaa86c6578eeac027056325761710c65531206fb3565c' 
  AND (
    token = 'hZ+NLdjIUmBVq3VCzDS9fcYguN9qEr/5QQbdr+Rge0o=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00034