Mike Bayer avatar Mike Bayer committed bf5be08

put becomes set

Comments (0)

Files changed (4)

docs/build/usage.rst

   the "front end" used by applications.
 * A *backend*, which is an instance of :class:`.CacheBackend`, describing how values
   are stored and retrieved from a backend.  This interface specifies only
-  :meth:`~.CacheBackend.get`, :meth:`~.CacheBackend.put` and :meth:`~.CacheBackend.delete`.
+  :meth:`~.CacheBackend.get`, :meth:`~.CacheBackend.set` and :meth:`~.CacheBackend.delete`.
   The actual kind of :class:`.CacheBackend` in use for a particular :class:`.CacheRegion`
   is determined by the underlying Python API being used to talk to the cache, such
   as Pylibmc.  The :class:`.CacheBackend` is instantiated behind the scenes and 
   not directly accessed by applications under normal circumstances.
 * Value generation functions.   These are user-defined functions that generate
   new values to be placed in the cache.   While dogpile.cache offers the usual
-  "put" approach of placing data into the cache, the usual mode of usage is to only instruct
+  "set" approach of placing data into the cache, the usual mode of usage is to only instruct
   it to "get" a value, passing it a *creation function* which will be used to 
   generate a new value if and only if one is needed.   This "get-or-create" pattern
   is the entire key to the "Dogpile" system, which coordinates a single value creation 
 .. automethod:: dogpile.cache.region.CacheRegion.get_or_create
     :noindex:
 
-.. automethod:: dogpile.cache.region.CacheRegion.put
+.. automethod:: dogpile.cache.region.CacheRegion.set
     :noindex:
 
 .. automethod:: dogpile.cache.region.CacheRegion.delete
         def get(self, key):
             return self.cache.get(key, NO_VALUE)
 
-        def put(self, key, value):
+        def set(self, key, value):
             self.cache[key] = value
 
         def delete(self, key):
 
     region = make_region("dictionary")
 
-    data = region.put("somekey", "somevalue")
+    data = region.set("somekey", "somevalue")
 
 The values we receive for the backend here are instances of
 ``CachedValue``.  This is a tuple subclass of length two, of the form::

dogpile/cache/api.py

         """
         raise NotImplementedError()
 
-    def put(self, key, value):
-        """Put a value in the cache.
+    def set(self, key, value):
+        """Set a value in the cache.
         
         The key will be whatever was passed
         to the registry, processed by the

dogpile/cache/region.py

 
         def gen_value():
             value = self._value(creator())
-            self.backend.put(key, value)
+            self.backend.set(key, value)
             return value
 
         dogpile = self.dogpile_registry.get(key)
                             "version":value_version
                         })
 
-    def put(self, key, value):
+    def set(self, key, value):
         """Place a new value in the cache under the given key."""
 
         if self.key_mangler:
             key = self.key_mangler(key)
-        self.backend.put(key, self._value(value))
+        self.backend.set(key, self._value(value))
 
 
     def delete(self, key):

tests/test_region.py

             return self._cache[key]
         except KeyError:
             return NO_VALUE
-    def put(self, key, value):
+    def set(self, key, value):
         self._cache[key] = value
     def delete(self, key):
         self._cache.pop(key, None)
     def test_key_mangler_impl(self):
         reg = self._region(init_args={"key_mangler":key_mangler})
 
-        reg.put("some key", "some value")
+        reg.set("some key", "some value")
         eq_(list(reg.backend._cache), ["HI!some key"])
         eq_(reg.get("some key"), "some value")
         eq_(reg.get_or_create("some key", lambda: "some new value"), "some value")
             getattr, reg, "backend"
         )
 
-    def test_put_get_value(self):
+    def test_set_get_value(self):
         reg = self._region()
-        reg.put("some key", "some value")
+        reg.set("some key", "some value")
         eq_(reg.get("some key"), "some value")
 
-    def test_put_get_nothing(self):
+    def test_set_get_nothing(self):
         reg = self._region()
         eq_(reg.get("some key"), NO_VALUE)
 
 
     def test_remove(self):
         reg = self._region()
-        reg.put("some key", "some value")
+        reg.set("some key", "some value")
         reg.delete("some key")
         reg.delete("some key")
         eq_(reg.get("some key"), NO_VALUE)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.