Documentation
¶
Index ¶
Constants ¶
View Source
const ( // NoExpiration For use with function that take an expiration time. NoExpiration time.Duration = -1 // DefaultExpiration For use with function that take an expiration time. Equivalent to // passing in the same expiration duration as was given to New() or // NewFrom() when the cache was created (e.g. 5 minutes.) DefaultExpiration time.Duration = 2 * time.Second )
Variables ¶
View Source
var ( DefaultExp time.Duration = 0 // default expiration CleanupInterval time.Duration = 0 //cleanup interval Size = 0 )
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
var (
Instance *Cache
)
func GetCacheInstance ¶
func GetCacheInstance() *Cache
GetCacheInstance : singleton implementation to retrieve THE cache
func New ¶
New Return a new cache with a given default expiration duration and cleanup interval. If the expiration duration is less than one (or NoExpiration), the items in the cache never expire (by default), and must be deleted manually. If the cleanup interval is less than one, expired items are not deleted from the cache before calling c.DeleteExpired().
func (Cache) Delete ¶
func (c Cache) Delete(k string)
Delete an item from the cache. Does nothing if the key is not in the cache. thread safe
func (Cache) DeleteExpired ¶
func (c Cache) DeleteExpired()
DeleteExpired Delete all expired items from the cache.
Click to show internal directories.
Click to hide internal directories.