Add a cache to workers KV storage implementation (#1284)

* cloudflare-cache

* go mod tidy
This commit is contained in:
Jake Sanders
2020-03-02 18:14:25 +00:00
committed by GitHub
parent 7cad77bfc0
commit f6102bde70
5 changed files with 45 additions and 2 deletions

View File

@@ -51,3 +51,13 @@ func Namespace(ns string) store.Option {
o.Namespace = ns
}
}
// CacheTTL sets the timeout in nanoseconds of the read/write cache
func CacheTTL(ttl int64) store.Option {
return func(o *store.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, "STORE_CACHE_TTL", ttl)
}
}