Documentation
¶
Index ¶
- Constants
- Variables
- func JSONPostPageCache(config Config, keys ...string) echo.MiddlewareFunc
- func SetCacheStore(store Store) echo.MiddlewareFunc
- type Config
- type InMemoryStore
- func (c *InMemoryStore) Add(key string, value interface{}, expires time.Duration) error
- func (c *InMemoryStore) Decrement(key string, n int64) (int64, error)
- func (c *InMemoryStore) Delete(key string) error
- func (c *InMemoryStore) Flush() error
- func (c *InMemoryStore) Get(key string, value interface{}) error
- func (c *InMemoryStore) Increment(key string, n int64) (int64, error)
- func (c *InMemoryStore) Replace(key string, value interface{}, expires time.Duration) error
- func (c *InMemoryStore) Set(key string, value interface{}, expires time.Duration) error
- type Store
Constants ¶
View Source
const ( // DefaultExpiration default expiration second DefaultExpiration = 5 * time.Second // StayForever no expiration StayForever = time.Duration(-1) // CacheMiddlewareKey key for cache middleware CacheMiddlewareKey = "echo-middleware.cache" )
Variables ¶
View Source
var ( PageCachePrefix = "echo-middleware.page.cache" ErrCacheMiss = errors.New("cache: key not found.") ErrNotStored = errors.New("cache: not stored.") ErrNotSupport = errors.New("cache: not support.") // DefaultCacheConfig is the default cache middleware config. DefaultCacheConfig = Config{ Expire: DefaultExpiration, Skipper: emw.DefaultSkipper, } )
Functions ¶
func JSONPostPageCache ¶
func JSONPostPageCache(config Config, keys ...string) echo.MiddlewareFunc
JSONPostPageCache middleware for page cache with json keys
func SetCacheStore ¶
func SetCacheStore(store Store) echo.MiddlewareFunc
SetCacheStore set cache store to context for next processes
Types ¶
type Config ¶
type Config struct { Expire time.Duration // Skipper defines a function to skip middleware. Skipper emw.Skipper }
Config defines the config for cache middleware.
type InMemoryStore ¶
func NewInMemoryStore ¶
func NewInMemoryStore(defaultExpiration time.Duration) *InMemoryStore
func (*InMemoryStore) Add ¶
func (c *InMemoryStore) Add(key string, value interface{}, expires time.Duration) error
func (*InMemoryStore) Decrement ¶
func (c *InMemoryStore) Decrement(key string, n int64) (int64, error)
func (*InMemoryStore) Delete ¶
func (c *InMemoryStore) Delete(key string) error
func (*InMemoryStore) Flush ¶
func (c *InMemoryStore) Flush() error
func (*InMemoryStore) Get ¶
func (c *InMemoryStore) Get(key string, value interface{}) error
func (*InMemoryStore) Increment ¶
func (c *InMemoryStore) Increment(key string, n int64) (int64, error)
type Store ¶
type Store interface { Get(key string, value interface{}) error Set(key string, value interface{}, expire time.Duration) error Add(key string, value interface{}, expire time.Duration) error Replace(key string, data interface{}, expire time.Duration) error Delete(key string) error Increment(key string, data int64) (int64, error) Decrement(key string, data int64) (int64, error) Flush() error }
Store defines the interface for cache store
Click to show internal directories.
Click to hide internal directories.