Documentation
¶
Index ¶
- type Cache
- func (dc *Cache) AddUpdateFunc(key string, updateFunc func() (interface{}, error))
- func (dc *Cache) Close()
- func (dc *Cache) Get(key string) (interface{}, bool)
- func (dc *Cache) Set(key string, data interface{})
- func (dc *Cache) StartUpdates(ctx context.Context, errorChannel chan error)
- func (dc *Cache) UpdateContent(ctx context.Context) error
- type Cacher
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
UpdateFuncs map[string]func() (interface{}, error)
// contains filtered or unexported fields
}
Cache contains all the information to start, update and close caching data
func NewCache ¶
NewCache create a cache object which will update at every updateInterval If updateInterval is nil, this means that the cache will only be updated once at the start of a service
func (*Cache) AddUpdateFunc ¶
AddUpdateFunc adds an update function to the cache for a specific data corresponding to the `key` passed to the function This update function will then be triggered once or at every fixed interval as per the prior setup of the TopicCache
func (*Cache) Close ¶
func (dc *Cache) Close()
Close closes the caching of data when called where the data will no longer be updated and the data itself is reset
func (*Cache) Get ¶
Get retrieves the specific value for the specified key stored in `data` within the `Cache`
func (*Cache) Set ¶
Set adds the specified value with the specified key in `data` within the `Cache`
func (*Cache) StartUpdates ¶
StartUpdates informs the cache to start updating the cache data once called and then at every update interval which was configured when setting up the cache