cache

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2019 License: GPL-3.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Mem = iota
	Redis
)
View Source
const (
	LRU = iota
	LFU
)

Variables

This section is empty.

Functions

func CopyHeaders

func CopyHeaders(dst, src http.Header)

CopyHeaders copies headers from source to destination. Nothing would be returned.

func IsReqCache

func IsReqCache(req *http.Request) bool

IsReqCache checks whether request ask to be stored as cache

func IsRespCache

func IsRespCache(resp *http.Response) bool

IsRespCache checks whether response can be stored as cache

func NewCachePool

func NewCachePool(cachePoolType CachePoolType) api.CachePool

Types

type CachePoolType added in v1.0.1

type CachePoolType int

type CacheReplacementPolicy added in v1.0.1

type CacheReplacementPolicy int

type HttpCache

type HttpCache struct {
	Header       http.Header `json:"header"`
	Body         []byte      `json:"body"`
	StatusCode   int         `json:"status_code"`
	URI          string      `json:"url"`
	LastModified string      `json:"last_modified"` //eg:"Fri, 27 Jun 2014 07:19:49 GMT"
	ETag         string      `json:"etag"`
	MustVerified bool        `json:"must_verified"`
	//Validity is a time when to verify the cache again.
	Validity time.Time `json:"validity"`
	// contains filtered or unexported fields
}

func NewCacheResp

func NewCacheResp(resp *http.Response) *HttpCache

func (*HttpCache) Verify

func (c *HttpCache) Verify() bool

Verify verifies whether cache is out of date.

func (*HttpCache) WriteTo

func (c *HttpCache) WriteTo(rw http.ResponseWriter) (int, error)

CacheHandler handles "Get" request

type MemConnCachePool added in v1.0.1

type MemConnCachePool struct {
	// contains filtered or unexported fields
}

func NewMemCachePool added in v1.0.1

func NewMemCachePool(cap int, crp CacheReplacementPolicy) *MemConnCachePool

func (*MemConnCachePool) CheckAndStore added in v1.0.1

func (c *MemConnCachePool) CheckAndStore(uri string, req *http.Request, resp *http.Response)

func (*MemConnCachePool) Delete added in v1.0.1

func (c *MemConnCachePool) Delete(uri string)

func (*MemConnCachePool) Get added in v1.0.1

func (c *MemConnCachePool) Get(uri string) api.Cache

type RedisConnCachePool added in v1.0.1

type RedisConnCachePool struct {
	// contains filtered or unexported fields
}

func NewRedisCachePool added in v1.0.1

func NewRedisCachePool(address, password string, idleTimeout, cap, maxIdle int) *RedisConnCachePool

func (*RedisConnCachePool) CheckAndStore added in v1.0.1

func (c *RedisConnCachePool) CheckAndStore(uri string, req *http.Request, resp *http.Response)

func (*RedisConnCachePool) Delete added in v1.0.1

func (c *RedisConnCachePool) Delete(uri string)

func (*RedisConnCachePool) Get added in v1.0.1

func (c *RedisConnCachePool) Get(uri string) api.Cache

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL