Documentation ¶
Overview ¶
Package cache provides an in-memory LRU cache for reducing the duplicate workload of database requests and post HTML and JSON generation
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Size sets the maximum size of cache before evicting unread data in MB Size float64 = 1 << 7 )
Functions ¶
Types ¶
type FrontEnd ¶
type FrontEnd struct { // GetCounter retrieves a new update counter for a resource GetCounter func(Key) (uint64, error) // GetFresh retrieves new post data from the database GetFresh func(Key) (interface{}, error) // Encode data into JSON. If null, default encoder is used. EncodeJSON func(data interface{}) ([]byte, error) // RenderHTML produces HTML from the passed in data and JSON RenderHTML func(interface{}, []byte) []byte // Calculates the size taken by the store. // If nil, the default function is used. Size func(data interface{}, json, html []byte) int }
FrontEnd provides functions for fetching, validating and generating the cache. GetCounter and GetFresh are mandatory, but you may omit RenderHTML, if you don't plan to call GetHTML with this FrontEnd.
Click to show internal directories.
Click to hide internal directories.