Documentation ¶
Index ¶
- Constants
- Variables
- type Cache
- func (c *Cache) Get(key string) (interface{}, bool)
- func (c *Cache) Invalidate()
- func (c *Cache) Len() int
- func (c *Cache) LogEvery(d time.Duration)
- func (c *Cache) PurgeEntries(keys []string)
- func (c *Cache) PurgeOldEntries()
- func (c *Cache) PurgedKeysAsString(keys []string) string
- func (c *Cache) Set(key string, label string, sizeBytes int, cacheObject interface{})
- func (c *Cache) SizeByte() int
- type CacheEntry
- type CacheStrategy
- func (tcs *CacheStrategy) Hash(method string, url string, requestHeader http.Header) string
- func (tcs *CacheStrategy) HashWithParameters(method string, url string, requestHeader http.Header, includeHeaders []string, ...) string
- func (tcs *CacheStrategy) IsCacheable(method string, url string, statusCode int, requestHeader http.Header, ...) bool
Constants ¶
View Source
const ( // The request method was POST and an Expiration header was not supplied. ReasonRequestMethodPOST = cacheobject.ReasonRequestMethodPOST // The request method was PUT and PUTs are not cachable. ReasonRequestMethodPUT = cacheobject.ReasonRequestMethodPUT // The request method was DELETE and DELETEs are not cachable. ReasonRequestMethodDELETE = cacheobject.ReasonRequestMethodDELETE // The request method was CONNECT and CONNECTs are not cachable. ReasonRequestMethodCONNECT = cacheobject.ReasonRequestMethodCONNECT // The request method was OPTIONS and OPTIONS are not cachable. ReasonRequestMethodOPTIONS = cacheobject.ReasonRequestMethodOPTIONS // The request method was TRACE and TRACEs are not cachable. ReasonRequestMethodTRACE = cacheobject.ReasonRequestMethodTRACE // The request method was not recognized by cachecontrol, and should not be cached. ReasonRequestMethodUnkown = cacheobject.ReasonRequestMethodUnkown // The request included an Cache-Control: no-store header ReasonRequestNoStore = cacheobject.ReasonRequestNoStore // The request included an Authorization header without an explicit Public or Expiration time: http://tools.ietf.org/html/rfc7234#section-3.2 ReasonRequestAuthorizationHeader = cacheobject.ReasonRequestAuthorizationHeader // The response included an Cache-Control: no-store header ReasonResponseNoStore = cacheobject.ReasonResponseNoStore // The response included an Cache-Control: private header and this is not a Private cache ReasonResponsePrivate = cacheobject.ReasonResponsePrivate // The response failed to meet at least one of the conditions specified in RFC 7234 section 3: http://tools.ietf.org/html/rfc7234#section-3 ReasonResponseUncachableByDefault = cacheobject.ReasonResponseUncachableByDefault )
Variables ¶
View Source
var DefaultCacheStrategy = NewCacheStrategyWithDefault()
View Source
var DefaultIncludeHeaders = []string{"Authorization", "Accept-Encoding", "Host"}
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a LRU cache with the following features - limits on max entries - memory size limit - ttl for entries
func (*Cache) Invalidate ¶
func (c *Cache) Invalidate()
func (*Cache) PurgeEntries ¶
Purge Entries with a specific hash
func (*Cache) PurgeOldEntries ¶
func (c *Cache) PurgeOldEntries()
PurgeOldEntries removes all entries which are out of their ttl
func (*Cache) PurgedKeysAsString ¶
type CacheEntry ¶
type CacheEntry struct {
// contains filtered or unexported fields
}
type CacheStrategy ¶
type CacheStrategy struct {
// contains filtered or unexported fields
}
func NewCacheStrategy ¶
func NewCacheStrategy(includeHeaders []string, includeCookies []string, ignoreReasons []cacheobject.Reason) *CacheStrategy
func NewCacheStrategyWithDefault ¶
func NewCacheStrategyWithDefault() *CacheStrategy
func (*CacheStrategy) Hash ¶
Hash computes a hash value based on the url, the method and selected header and cookie attributes.
func (*CacheStrategy) HashWithParameters ¶
func (tcs *CacheStrategy) HashWithParameters(method string, url string, requestHeader http.Header, includeHeaders []string, includeCookies []string) string
Hash computes a hash value based on the url, the method and selected header and cookie attributes.
Click to show internal directories.
Click to hide internal directories.