UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'gEldH1qIMN2VmnDpq00njLQBdRxNbZMA6CBN6s13+hk=' 
WHERE 
  key_id = '9f4dab5a45b96188a148668cfa69a4a22693376f4d994077633247b03572cb94' 
  AND (
    token = 'gEldH1qIMN2VmnDpq00njLQBdRxNbZMA6CBN6s13+hk=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00024