Documentation ¶
Index ¶
- type Cache
- type CacheWrapper
- type GoCache
- type SandCache
- func (sc *SandCache) Delete(key string)
- func (sc *SandCache) DirectWrite(key string, value interface{}, exp time.Duration)
- func (sc *SandCache) Read(key string, marginSec float64) interface{}
- func (sc *SandCache) ReadRaw(key string, marginSec float64) *CacheWrapper
- func (sc *SandCache) ReadSecondaryRaw(key string, marginSec float64) (wrapper *CacheWrapper)
- func (sc *SandCache) Write(key string, value interface{}, exp time.Duration) (data interface{}, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface { Read(string) interface{} Write(string, interface{}, time.Duration) error Delete(string) Clear() }
Cache is an interface for caches
type CacheWrapper ¶
type CacheWrapper struct { Data interface{} ExpiresAtUnixNano int64 }
type GoCache ¶
type GoCache struct {
cache.Cache
}
Implements our Cache interface
func NewGoCache ¶
NewGoCache creates a new GoCache.
type SandCache ¶
type SandCache struct { Secondary Cache // contains filtered or unexported fields }
SandCache contains a primary and an optional secondary cache. The primary cache is an in-memory cache. If the secondary cache is nil, the primary will still be used. The main purpose for the secondary cache is to use a central cache (like a TLS-enabled Redis) shared by multiple processes/servers of the same app, so that they can coordinate on the cached data.
func NewSandCache ¶
NewSandCache creates a primary cache with the defaultExpTime as default expiration time. The secondary cache should be a central cache shared by multiple processes or servers.
func (*SandCache) DirectWrite ¶
func (*SandCache) ReadRaw ¶
func (sc *SandCache) ReadRaw(key string, marginSec float64) *CacheWrapper
func (*SandCache) ReadSecondaryRaw ¶
func (sc *SandCache) ReadSecondaryRaw(key string, marginSec float64) (wrapper *CacheWrapper)