diff --git a/README.md b/README.md index d24aa6f..1afa8ad 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,8 @@ go get github.com/gookit/gsr ## Interfaces - [logger](logger.go) -- [simple cache](simple_cache.go) +- [cacher](cacher.go) +- [marshaler](marshaler.go) ## Usage diff --git a/simple_cache.go b/cacher.go similarity index 73% rename from simple_cache.go rename to cacher.go index 3d5c657..b34c851 100644 --- a/simple_cache.go +++ b/cacher.go @@ -7,17 +7,15 @@ import ( // SimpleCacher interface definition type SimpleCacher interface { - // Closer close + // Closer close cache handle io.Closer - // Clear clear + // Clear clear all caches Clear() error // Has basic operation Has(key string) bool Del(key string) error Get(key string) interface{} - // GetAs get cache value and unmarshal as ptr. - GetAs(key string, ptr interface{}) error Set(key string, val interface{}, ttl time.Duration) error // GetMulti multi operation @@ -25,3 +23,11 @@ type SimpleCacher interface { SetMulti(values map[string]interface{}, ttl time.Duration) error DelMulti(keys []string) error } + +// CodedCacher interface. +type CodedCacher interface { + SimpleCacher + + // GetAs get and decode cache value to object ptr + GetAs(key string, ptr interface{}) error +}