Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultCacheConfig defines default values for CacheConfig DefaultCacheConfig = CacheConfig{ Skipper: middleware.DefaultSkipper, Expiration: 3 * time.Minute, } )
var DefaultCacheMemoryStoreConfig = CacheMemoryStoreConfig{ Capacity: 10, Algorithm: LRU, }
DefaultCacheMemoryStoreConfig provides default configuration values for CacheMemoryStoreConfig
Functions ¶
func Cache ¶
func Cache(store CacheStore) echo.MiddlewareFunc
Cache returns a cache middleware
e := echo.New()
... 추가 설명
func CacheWithConfig ¶
func CacheWithConfig(config CacheConfig) echo.MiddlewareFunc
CacheWithConfig returns a cache middleware
Types ¶
type CacheConfig ¶
type CacheConfig struct { // Skipper defines a function to skip middleware. Skipper middleware.Skipper Store CacheStore Expiration time.Duration // default expiration IncludePaths []string IncludePathsWithExpiration map[string]time.Duration // key: path, value: expiration //IncludePathsWithExpiration has higher priority ExcludePaths []string }
CacheConfig data structure for HTTP cache middleware.
type CacheMemoryStore ¶
type CacheMemoryStore struct {
// contains filtered or unexported fields
}
CacheMemoryStore is the built-in store implementation for Cache
func NewCacheMemoryStore ¶
func NewCacheMemoryStore() (store *CacheMemoryStore)
func NewCacheMemoryStoreWithConfig ¶
func NewCacheMemoryStoreWithConfig(config CacheMemoryStoreConfig) (store *CacheMemoryStore)
func (*CacheMemoryStore) Get ¶
func (store *CacheMemoryStore) Get(key uint64) ([]byte, bool)
Get implements the cache Adapter interface Get method.
func (*CacheMemoryStore) Release ¶
func (store *CacheMemoryStore) Release(key uint64)
Release implements the Adapter interface Release method.
type CacheMemoryStoreConfig ¶
CacheMemoryStoreConfig represents configuration for CacheMemoryStoreConfig
type CacheRedisClusterStore ¶
type CacheRedisClusterStore struct {
// contains filtered or unexported fields
}
CacheRedisClusterStore is the redis cluster store
func (*CacheRedisClusterStore) Get ¶
func (store *CacheRedisClusterStore) Get(key uint64) ([]byte, bool)
Get implements the cache CacheRedisClusterStore interface Get method.
func (*CacheRedisClusterStore) Release ¶
func (store *CacheRedisClusterStore) Release(key uint64)
Release implements the cache CacheRedisClusterStore interface Release method.
type CacheRedisStore ¶
type CacheRedisStore struct {
// contains filtered or unexported fields
}
CacheRedisStore is the redis standalone store implementation for Cache
func (*CacheRedisStore) Get ¶
func (store *CacheRedisStore) Get(key uint64) ([]byte, bool)
Get implements the cache CacheRedisClusterStore interface Get method.
func (*CacheRedisStore) Release ¶
func (store *CacheRedisStore) Release(key uint64)
type CacheResponse ¶
type CacheResponse struct { // URL is URL URL string `json:"url"` // Header is the cached response header. Header http.Header `json:"header"` // Body is the cached response value. Body []byte `json:"body"` // Expiration is the cached response Expiration date. Expiration time.Time `json:"expiration"` // LastAccess is the last date a cached response was accessed. // Used by LRU and MRU algorithms. LastAccess time.Time `json:"lastAccess"` // Frequency is the count of times a cached response is accessed. // Used for LFU and MFU algorithms. Frequency int `json:"frequency"` }
CacheResponse is the cached response data structure.
type CacheStore ¶
type CacheStore interface { // Get retrieves the cached response by a given key. It also // returns true or false, whether it exists or not. Get(key uint64) ([]byte, bool) // Set caches a response for a given key until an Expiration date. Set(key uint64, response []byte, expiration time.Time) // Release frees cache for a given key. Release(key uint64) }
CacheStore is the interface to be implemented by custom stores.
func NewCacheRedisClusterWithConfig ¶
func NewCacheRedisClusterWithConfig(opt redis.RingOptions) CacheStore
NewCacheRedisClusterWithConfig initializes Redis adapter.
func NewCacheRedisStoreWithConfig ¶
func NewCacheRedisStoreWithConfig(opt redis.Options) CacheStore