title: Caching with Python dictionary
body: <p>I am trying to add data to a dictionary but I do not want to overwrite the whole dictionary with the new one. I want to append the new data to the old data in the dictionary.
  I implemented a similar logic in Javascript using maps but I can't seem to pull it off with python. I don't know what I am missing in my logic.
  Anytime I add a new data the old ones disappears. Is there a way to create a memoization or caching with python?</p>
  
  <pre class="lang-py prettyprint-override"><code>class CacheService():
  
      def __init__(self):
          self.data = dict()
  
      def __setitem__(self, key, item):
          self.data[key] = item
  
      def __getitem__(self, key):
          return self.data[key]
  
      def __str__(self):
          return str(self.data)
  
      def getCount(self):
          return len(self.data)
  </code></pre>
  
  <hr>
  
  <pre class="lang-py prettyprint-override"><code>from cache import CacheService
  
  class Action:
  
      def __init__(self):
          self.cache_service = CacheService()
  
      def add(self, args):
          try:
              with open(args) as file:
                  new_data = file.readlines()
                  first, last, age = [value for values in new_data for value in values.split() ]
                  #check if user already exist
                  self.cache_service['first'] = first
                  self.cache_service['last'] = last
                  self.cache_service['age'] = age
                  print(self.cache_service)
          except IOError as e:
              print('Unable to Open file', e)
  </code></pre>
  
  <pre><code>    from controller.action import Action
  
      class App():
  
          def add(self, args):
              make_action = Action()
              make_action.add(args)
      ```
  </code></pre>