httpcache: Index | Files

package entry

import ""


Package Files

entry.go response.go util.go

func ParseMaxAge Uses

func ParseMaxAge(header string) int64

ParseMaxAge parses the max age from the receiver parameter, "cache-control" header returns seconds as int64 if header not found or parse failed then it returns -1

type Entry Uses

type Entry struct {
    // contains filtered or unexported fields

Entry is the cache entry contains the expiration datetime and the response

func NewEntry Uses

func NewEntry(duration time.Duration) *Entry

NewEntry returns a new cache entry it doesn't sets the expiresAt & the response because these are setting each time on Reset

func (*Entry) ChangeLifetime Uses

func (e *Entry) ChangeLifetime(fdur LifeChanger)

ChangeLifetime modifies the life field which is the life duration of the cached response of this cache entry

useful when we find a max-age header from the handler

func (*Entry) Reset Uses

func (e *Entry) Reset(statusCode int, contentType string,
    body []byte, lifeChanger LifeChanger)

Reset called each time the entry is expired and the handler calls this after the original handler executed to re-set the response with the new handler's content result

func (*Entry) Response Uses

func (e *Entry) Response() (*Response, bool)

Response gets the cache response contents if it's valid returns them with a true value otherwise returns nil, false

type LifeChanger Uses

type LifeChanger func() time.Duration

LifeChanger is the function which returns a duration which will be compared with the current entry's (cache life) duration and execute the LifeChanger func to set the new life time

type Response Uses

type Response struct {
    // contains filtered or unexported fields

Response is the cached response will be send to the clients its fields setted at runtime on each of the non-cached executions non-cached executions = first execution, and each time after cache expiration datetime passed

func (*Response) Body Uses

func (r *Response) Body() []byte

Body returns contents will be served by the cache handler

func (*Response) ContentType Uses

func (r *Response) ContentType() string

ContentType returns a valid content type

func (*Response) StatusCode Uses

func (r *Response) StatusCode() int

StatusCode returns a valid status code

Package entry imports 4 packages (graph). Updated 2017-04-12. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).