Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
Cache defines the methods LoadWithUpdate and Store, the user needs to define the function `update`.
func New ¶
New returns the *Cache. the function update, if found new *item, returns true, and stores it; else returns false, and delete the key from cache.
func (*Cache) LoadWithUpdate ¶
LoadWithUpdate loads the cached item. If the item is not cached, it returns the newest and caches the new item. If the time is cached, it returns the item. if the cached item is expired, it returns the current item and tries to cache the newest.
func (*Cache) LoadWithUpdateSync ¶
LoadWithUpdateSync loads the cached item. If the item is not cached, it returns the newest and caches the new item. If the item is cached, it returns the item. If the cached item is expired, it tries to retrieve the newest then caches and returns it.