Documentation
¶
Index ¶
- type TimedCache
- func (tc *TimedCache) GetByID(key int64) (value interface{}, keyName string, ok bool)
- func (tc *TimedCache) GetByName(name string) (value interface{}, ok bool)
- func (tc *TimedCache) GetNameID(keyName string) (nameID int64, ok bool)
- func (tc *TimedCache) Purge()
- func (tc *TimedCache) PurgeNames()
- func (tc *TimedCache) RemoveID(key int64)
- func (tc *TimedCache) RemoveName(name string)
- func (tc *TimedCache) Set(name string, id int64, value interface{})
- func (tc *TimedCache) SetID(id int64, value interface{})
- func (tc *TimedCache) UnlinkName(keyName string)
- func (tc *TimedCache) UnlinkNamePrefix(namePrefix string)
- func (tc *TimedCache) Update(id int64, value interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TimedCache ¶
type TimedCache struct { sync.Mutex //Necessary to use the nameMap // contains filtered or unexported fields }
TimedCache is an lru cache with an additional expiration time for the data in each element It is not a very clever cache, and does not factor in time expiration in lru
func NewTimedCache ¶
func NewTimedCache(size int, expireTime int64, err error) (*TimedCache, error)
NewTimedCache returns the TimedCache with given parameters
func (*TimedCache) GetByID ¶
func (tc *TimedCache) GetByID(key int64) (value interface{}, keyName string, ok bool)
GetByID gets an element if it is cached and not yet expired
func (*TimedCache) GetByName ¶
func (tc *TimedCache) GetByName(name string) (value interface{}, ok bool)
GetByName gets an element if it is in the cache and not expired
func (*TimedCache) GetNameID ¶
func (tc *TimedCache) GetNameID(keyName string) (nameID int64, ok bool)
GetNameID gets the ID associated with a name
func (*TimedCache) PurgeNames ¶
func (tc *TimedCache) PurgeNames()
PurgeNames clears all the names from the cache, but leaves the cache elements accessible by ID
func (*TimedCache) RemoveID ¶
func (tc *TimedCache) RemoveID(key int64)
RemoveID the given key from the cache by ID
func (*TimedCache) RemoveName ¶
func (tc *TimedCache) RemoveName(name string)
RemoveName deletes the cache element by its name
func (*TimedCache) Set ¶
func (tc *TimedCache) Set(name string, id int64, value interface{})
Set adds a new element to the cache
func (*TimedCache) SetID ¶
func (tc *TimedCache) SetID(id int64, value interface{})
SetID sets a new element without knowing its name
func (*TimedCache) UnlinkName ¶
func (tc *TimedCache) UnlinkName(keyName string)
UnlinkName unlinks the name fro mthe ID
func (*TimedCache) UnlinkNamePrefix ¶
func (tc *TimedCache) UnlinkNamePrefix(namePrefix string)
UnlinkNamePrefix removes all names with the given prefix. This is not a very efficient way to do it, since it loops through the entire cache unlinking names. It locks queries by name for the entire time.
func (*TimedCache) Update ¶
func (tc *TimedCache) Update(id int64, value interface{})
Update an element without changing the associated name