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

Unified Diff: filter/dscache/context.go

Issue 1579853002: Add dscache.AlwaysFilterRDS function. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: add comment Created 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: filter/dscache/context.go
diff --git a/filter/dscache/context.go b/filter/dscache/context.go
index a9f10ba1de6fbf0955edf5800ce4f3842925c0e6..87477802d1b16865193911103de8c36ce683e4e8 100644
--- a/filter/dscache/context.go
+++ b/filter/dscache/context.go
@@ -18,6 +18,10 @@ var dsTxnCacheKey key
// FilterRDS installs a caching RawDatastore filter in the context.
//
+// It does nothing if IsGloballyEnabled returns false. That way it is possible
+// to disable the cache in runtime (e.g. in case memcache service is having
+// issues).
+//
// shardsForKey is a user-controllable function which calculates the number of
// shards to use for a certain datastore key. The provided key will always be
// valid and complete.
@@ -32,7 +36,14 @@ func FilterRDS(c context.Context, shardsForKey func(*ds.Key) int) context.Contex
if !IsGloballyEnabled(c) {
return c
}
+ return AlwaysFilterRDS(c, shardsForKey)
+}
+// AlwaysFilterRDS installs a caching RawDatastore filter in the context.
+//
+// Unlike FilterRDS it doesn't check GlobalConfig via IsGloballyEnabled call,
+// assuming caller already knows whether filter should be applied or not.
+func AlwaysFilterRDS(c context.Context, shardsForKey func(*ds.Key) int) context.Context {
return ds.AddRawFilters(c, func(c context.Context, ds ds.RawInterface) ds.RawInterface {
i := info.Get(c)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698