title: How should I write a function in Python that check whether a user has fetched some url or not?
body: <p>I'm studying Python and I'd like to have some hints on how to write it as I read about the implementation of a fetch(url) function as follows:</p>
  <pre><code>_cache = {}
  def fetch(url):
      user = os.environ['USER']
      if user not in _cache:
          _cache[user] = {}
      if url not in _cache[user]:
          _cache[user][url] = requests.get(url).content
      return _cache[user][url]
  </code></pre>
  <p>and I'm trying to figure out how to modify this kind of function  in order it checks wether a user has fetched some url or not, assuming that fetching a resource from web might take 0.1 seconds, while fetching it on the cache provides an instant result.</p>
  <p>It should be something like</p>
  <pre><code>import sys # ignore
  sys.path.insert(0,'.') # ignore
  from Root.fetch import fetch
  
  
  def did_fetch(user, url):
      pass #return if url has been fatched by user
  </code></pre>
  <p>with the function to be implemented inside</p>