Documentation ¶
Overview ¶
Package cache is a midware thats stores one signature, composed of fields with information about the document that is accessed, with that signature one document is identified and the validit of it is considered for the sacke of cache.
Index ¶
- Constants
- func Cache(expire time.Duration, cs *Storage, meta Meta, f http.HandlerFunc) http.HandlerFunc
- type Document
- type Image
- func (i *Image) ComposeFileName(r *http.Request)
- func (i *Image) Modification() time.Time
- func (i *Image) Name() string
- func (i *Image) New(m time.Time) Document
- func (i *Image) OutDate(cached Document) bool
- func (i *Image) Path() string
- func (i *Image) RootDirHash() string
- func (i *Image) Sulfix() string
- type Meta
- type Storage
- type Text
Constants ¶
const ErrNoStats = "no stat for file %v"
ErrNoStats - error for the file thant hanven't stat information.
Variables ¶
This section is empty.
Functions ¶
func Cache ¶
func Cache(expire time.Duration, cs *Storage, meta Meta, f http.HandlerFunc) http.HandlerFunc
Cache handler check with version do to the user, cached or a new one. Cache sets too the header cache specific values.
Types ¶
type Document ¶
type Document interface { OutDate(cached Document) bool Name() string Path() string Modification() time.Time RootDirHash() string New(m time.Time) Document Sulfix() string }
Document interface give access to cache control functions for the documents struct.
type Image ¶
type Image struct { FileName string MTime time.Time Lang string Mime string UserAgent string //ResponseCode string Hash string Width int Height int Extension string }
Image represents the metadata, cache relevant information. The local version.
func (*Image) ComposeFileName ¶
ComposeFileName creates the file name from the data find in the request.
func (*Image) Modification ¶
Modification shows the time of modification of the doc.
func (*Image) New ¶
New returns a new doc with the same metadata but the mtime. The new mtime will come from the cached version of the doc.
func (*Image) OutDate ¶
OutDate tells if the cache is out of date in relation to the original image.
func (*Image) RootDirHash ¶
RootDirHash make a hash that is used in the root dir. This root dir name will identify a group of documents with the same caracteristics.
type Meta ¶
Meta function collects all data about the document and put it a struct suitable to the cache handler.
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage is where the data is cached.
func NewStorage ¶
NewStorage creates a new place to store que documents in cache.
func (*Storage) Close ¶
func (s *Storage) Close()
Close terminates the gorotime associetade with this storage.
func (*Storage) GetMTime ¶
GetMTime retrive the mtime of document with metadata in d and return one document with the same metadata plus the mtime of the cache.
type Text ¶
type Text struct { FileName string MTime time.Time Lang string Encoding string Mime string UserAgent string // Extension must start with a dot Extension string //ResponseCode string // Hash the template data. Hash string }
Text represents the document. The local version.
func (*Text) ComposeFileName ¶
ComposeFileName creates the file name from the data find in the request.
func (*Text) Modification ¶
Modification shows the time of modification of the doc.
func (*Text) New ¶
New returns a new doc with the same metadata but the mtime. The new mtime will come from the cached version of the doc.
func (*Text) RootDirHash ¶
RootDirHash make a hash that is used in the root dir. This root dir name will identify a group of documents with the same caracteristics.