def _Dynamic_Set(self, request, response):
    namespace = request.name_space()
    for item in request.item_list():
      key = item.key()
      set_policy = item.set_policy()
      old_entry = self._GetKey(namespace, key)

      set_status = MemcacheSetResponse.NOT_STORED
      if ((set_policy == MemcacheSetRequest.SET) or
          (set_policy == MemcacheSetRequest.ADD and old_entry is None) or
          (set_policy == MemcacheSetRequest.REPLACE and old_entry is not None)):

        if (old_entry is None or
            set_policy == MemcacheSetRequest.SET
            or not old_entry.CheckLocked()):
          if namespace not in self._the_cache:
            self._the_cache[namespace] = {}
          self._the_cache[namespace][key] = CacheEntry(item.value(),
                                                       item.expiration_time(),
                                                       item.flags(),
                                                       gettime=self._gettime)
          set_status = MemcacheSetResponse.STORED

      response.add_set_status(set_status)
Implementation of MemcacheService::Set().
dataset/ETHPy150Open CollabQ/CollabQ/.google_appengine/google/appengine/api/memcache/memcache_stub.py/MemcacheServiceStub._Dynamic_Set