Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Unified Diff: third_party/google-endpoints/dogpile/cache/backends/null.py

Issue 2666783008: Add google-endpoints to third_party/. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/google-endpoints/dogpile/cache/backends/null.py
diff --git a/third_party/google-endpoints/dogpile/cache/backends/null.py b/third_party/google-endpoints/dogpile/cache/backends/null.py
new file mode 100644
index 0000000000000000000000000000000000000000..603cca3f61b15ea689f4c35c45acbd9026720f1f
--- /dev/null
+++ b/third_party/google-endpoints/dogpile/cache/backends/null.py
@@ -0,0 +1,62 @@
+"""
+Null Backend
+-------------
+
+The Null backend does not do any caching at all. It can be
+used to test behavior without caching, or as a means of disabling
+caching for a region that is otherwise used normally.
+
+.. versionadded:: 0.5.4
+
+"""
+
+from ..api import CacheBackend, NO_VALUE
+
+
+__all__ = ['NullBackend']
+
+
+class NullLock(object):
+ def acquire(self, wait=True):
+ return True
+
+ def release(self):
+ pass
+
+
+class NullBackend(CacheBackend):
+ """A "null" backend that effectively disables all cache operations.
+
+ Basic usage::
+
+ from dogpile.cache import make_region
+
+ region = make_region().configure(
+ 'dogpile.cache.null'
+ )
+
+ """
+
+ def __init__(self, arguments):
+ pass
+
+ def get_mutex(self, key):
+ return NullLock()
+
+ def get(self, key):
+ return NO_VALUE
+
+ def get_multi(self, keys):
+ return [NO_VALUE for k in keys]
+
+ def set(self, key, value):
+ pass
+
+ def set_multi(self, mapping):
+ pass
+
+ def delete(self, key):
+ pass
+
+ def delete_multi(self, keys):
+ pass

Powered by Google App Engine
This is Rietveld 408576698