Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a hash tree of keys which have been hashed using SipHash. It stores pointers to the values associated with the keys. It supports customisable key Time To Live and scavenge time.
func NewCache ¶
NewCache will return a pointer to a newly instantiated Cache. It requires a 128 bit hash key in string form to initialise. If the key is longer or shorter than 128 bits it will be truncated or padded respectively. The cache TTL and scavenge time are set to 10 seconds and 1 second respectively. These values can be changed at any time by calling the SetTTL and SetScavengeTime methods.
func (*Cache) Read ¶
Read will try to read the value of a given key from the cache. It will return the data as []byte and true if the key is found, otherwise it will return false if the key isn't found.
func (*Cache) SetScavengeTime ¶
SetScavengeTime sets the frequency (in milliseconds) that the cache will check for entries that are older than their TTL. It must be greater than 0 milliseconds, and less than or equal to the cache TTL.