UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'ZqjdKr7/GxbTf874YL+DpxYF41aCiatD4ei+1OrMSwA=' 
WHERE 
  key_id = '7812e40de173505302a6364e6dafcf6de721132361583707f76cc971c6ce1e12' 
  AND (
    token = 'ZqjdKr7/GxbTf874YL+DpxYF41aCiatD4ei+1OrMSwA=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00050