cache

package
v0.0.0-...-6b4cc3a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package cache is a simple global cache implementation call StartCache() to start the cache thread. then use

AddToCache, FlushCache, RemoveFromCache and FetchFromCache as necessary

Index

Constants

View Source
const (
	CacheTypeResource             = "static:"
	CacheTypePlugin               = "Plugin:"
	CacheTypeDatabase             = "Database:"
	CacheTypeTemplateHelperPlugin = "templateHelperPlugin:"
)

cache object "types"

View Source
const MaxTTL = time.Duration(^(uint64(1) << 63))

MaxTTL is the max possible TTL value (aprox 290 years)

Variables

This section is empty.

Functions

func AddCacheSettingDecoders

func AddCacheSettingDecoders()

AddCacheSettingDecoders adds setting decoders for cache settings in config file

func AddToCache

func AddToCache(cacheType string, name string, object interface{})

AddToCache caches a object under the given cacheType + name combination.

func AddToCacheTTLOverride

func AddToCacheTTLOverride(cacheType string, name string, ttl time.Duration, object interface{})

AddToCacheTTLOverride is like AddToCache but allows overriding of global ttl value.

func FetchAllOfType

func FetchAllOfType(cacheType string) []interface{}

FetchAllOfType returns every object in the cache of the given type

func FetchFromCache

func FetchFromCache(cacheType string, name string) interface{}

FetchFromCache attempts to fetch the object denoted by cacheType + name from the cache. If such an object does not exist in the cache nil is returned.

func FlushCache

func FlushCache()

FlushCache removes all objects from the cache

func FlushCacheByType

func FlushCacheByType(cacheType string)

FlushCacheByType removes all objects in the cache that have the given type

func RemoveFromCache

func RemoveFromCache(cacheType string, name string)

RemoveFromCache removes the object denoted by cacheType + name from the cache.

func StartCache

func StartCache()

StartCache starts cache management thread. CALL THIS FIRST

func UpdateCacheTTL

func UpdateCacheTTL(newTTL time.Duration)

UpdateCacheTTL set a new ttl for cache objects (objects already in cache uneffected)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL