github.com/angenalZZZ/gofunc@v0.0.0-20210507121333-48ff1be3917b/data/cache/interface.go (about) 1 package cache 2 3 import ( 4 "github.com/angenalZZZ/gofunc/data/cache/codec" 5 "github.com/angenalZZZ/gofunc/data/cache/store" 6 "time" 7 ) 8 9 // Interface represents the interface for all caches (aggregates, metric, memory, redis, ...) 10 type Interface interface { 11 Get(key string) (interface{}, error) 12 Set(key string, object interface{}, options *store.Options) error 13 TTL(key string) (time.Duration, error) 14 Delete(key string) error 15 Invalidate(options store.InvalidateOptions) error 16 Clear() error 17 GetType() string 18 } 19 20 // StorageInterface represents the interface for caches that allows 21 // storage (for instance: memory, redis, ...) 22 type StorageInterface interface { 23 Interface 24 25 GetCodec() codec.CodecInterface 26 }