{"modulePath":"github.com/ExecutionLab/echo-http-cache","version":"v0.0.0-20220223032154-3410f9d29a59","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package cache\n\n## Functions\n\n```go\nfunc KeyAsString(key uint64) string\n```\nKeyAsString can be used by adapters to convert the cache key from uint64 to string.\n\n## Types\n\n```go\ntype Adapter interface {\n\t// Get retrieves the cached response by a given key. It also\n\t// returns true or false, whether it exists or not.\n\tGet(key uint64) ([]byte, bool)\n\n\t// Set caches a response for a given key until an expiration date.\n\tSet(key uint64, response []byte, expiration time.Time)\n\n\t// Release frees cache for a given key.\n\tRelease(key uint64)\n}\n```\nAdapter interface for HTTP cache middleware client.\n\n```go\ntype Client struct {\n\t// contains filtered or unexported fields\n}\n```\nClient data structure for HTTP cache middleware.\n\n```go\nfunc NewClient(opts ...ClientOption) (*Client, error)\n```\nNewClient initializes the cache HTTP middleware client with the given options.\n\n```go\nfunc (client *Client) Middleware() echo.MiddlewareFunc\n```\nMiddleware is the HTTP cache middleware handler.\n\n```go\ntype ClientOption func(c *Client) error\n```\nClientOption is used to set Client settings.\n\n```go\nfunc ClientWithAdapter(a Adapter) ClientOption\n```\nClientWithAdapter sets the adapter type for the HTTP cache middleware client.\n\n```go\nfunc ClientWithMethods(methods []string) ClientOption\n```\nClientWithMethods sets the acceptable HTTP methods to be cached. Optional setting. If not set, default is \"GET\".\n\n```go\nfunc ClientWithRefreshKey(refreshKey string) ClientOption\n```\nClientWithRefreshKey sets the parameter key used to free a request cached response. Optional setting.\n\n```go\nfunc ClientWithRestrictedPaths(paths []string) ClientOption\n```\nClientWithRestrictedPaths sets the restricted HTTP paths for caching. Optional setting.\n\n```go\nfunc ClientWithTTL(ttl time.Duration) ClientOption\n```\nClientWithTTL sets how long each response is going to be cached.\n\n```go\ntype Response struct {\n\t// Value is the cached response value.\n\tValue []byte\n\n\t// Header is the cached response header.\n\tHeader http.Header\n\n\t// Expiration is the cached response expiration date.\n\tExpiration time.Time\n\n\t// LastAccess is the last date a cached response was accessed.\n\t// Used by LRU and MRU algorithms.\n\tLastAccess time.Time\n\n\t// Frequency is the count of times a cached response is accessed.\n\t// Used for LFU and MFU algorithms.\n\tFrequency int\n}\n```\nResponse is the cached response data structure.\n\n```go\nfunc BytesToResponse(b []byte) Response\n```\nBytesToResponse converts bytes array into Response data structure.\n\n```go\nfunc (r Response) Bytes() []byte\n```\nBytes converts Response data structure into bytes array.\n\n","path":"github.com/ExecutionLab/echo-http-cache","name":"cache","synopsis":"","isRedistributable":true}
