Documentation
¶
Index ¶
- type Cache
- type DoFn
- type KeyValCache
- func (k *KeyValCache) Delete(ctx context.Context, key string) error
- func (k *KeyValCache) Get(ctx context.Context, key string, value interface{}) error
- func (k *KeyValCache) HealthCheck(ctx context.Context) error
- func (k *KeyValCache) Keys(ctx context.Context, key string) ([]string, error)
- func (k *KeyValCache) Set(ctx context.Context, key string, value interface{}) error
- type MemCache
- func (m MemCache) Delete(ctx context.Context, key string) error
- func (m MemCache) Get(ctx context.Context, key string, v interface{}) error
- func (m MemCache) HealthCheck(ctx context.Context) error
- func (m MemCache) Keys(ctx context.Context, key string) ([]string, error)
- func (m MemCache) Set(ctx context.Context, key string, value interface{}) error
- type MemoizeMetrics
- type MetricsCache
- func (c MetricsCache) Delete(ctx context.Context, key string) (err error)
- func (c MetricsCache) Get(ctx context.Context, key string, v interface{}) (err error)
- func (c MetricsCache) HealthCheck(ctx context.Context) error
- func (c MetricsCache) Keys(ctx context.Context, key string) ([]string, error)
- func (c MetricsCache) Set(ctx context.Context, key string, value interface{}) (err error)
- type Options
- type Wrapper
- func (wrapper *Wrapper) Contains(key interface{}) bool
- func (wrapper *Wrapper) Get(key interface{}) (value interface{}, ok bool)
- func (wrapper *Wrapper) Keys() []interface{}
- func (wrapper *Wrapper) Len() int
- func (wrapper *Wrapper) Purge()
- func (wrapper *Wrapper) Remove(key interface{}) (present bool)
- func (wrapper *Wrapper) Resize(size int) (evicted int)
- func (wrapper *Wrapper) Set(key interface{}, value interface{}) (evicted bool)
- func (wrapper *Wrapper) SetLogger(l logger.Logger)
- func (wrapper *Wrapper) Updated() time.Time
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface { // Set sets a value in the cache for a given key and field Set(ctx context.Context, key string, value interface{}) error // Get gets the value of a field for a given key Get(ctx context.Context, key string, value interface{}) error // Delete removes a key from the cache Delete(ctx context.Context, key string) error // Keys returns a list of keys that match the pattern Keys(ctx context.Context, key string) ([]string, error) // HealthCheck checks cache health HealthCheck(ctx context.Context) error }
Cache is the interface for a key value cache
func NewMemoizeCache ¶
func NewMemoizeCache(rc redis.UniversalClient, defaultExpiration, cleanupInterval time.Duration, metrics memoizeMetrics) Cache
NewMemoizeCache creates a memoize cache
type DoFn ¶
type DoFn func(item *cache.Item) (interface{}, error)
DoFn returns the item to be cached
type KeyValCache ¶
type KeyValCache struct {
// contains filtered or unexported fields
}
KeyValCache is a cache that stores KeyValue pairs
func NewKeyValCache ¶
func NewKeyValCache(rc redis.UniversalClient, opts ...Options) *KeyValCache
NewKeyValCache instantiates and returns a KeyValCache
func (*KeyValCache) Delete ¶
func (k *KeyValCache) Delete(ctx context.Context, key string) error
Delete can be used to forcefully remove a key from the cache before it's TTL has expired
func (*KeyValCache) Get ¶
func (k *KeyValCache) Get(ctx context.Context, key string, value interface{}) error
Get gets a value from the cache specified by the key
func (*KeyValCache) HealthCheck ¶
func (k *KeyValCache) HealthCheck(ctx context.Context) error
HealthCheck pings the underlying redis cache
type MemCache ¶
MemCache is an in memory cache that stores a map of keys to a map of fields and their values
func (MemCache) HealthCheck ¶
HealthCheck checks cache health we don't have any connection to check here so just return no errors
type MemoizeMetrics ¶
type MemoizeMetrics struct {
// contains filtered or unexported fields
}
MemoizeMetrics implements the memoizeMetrics interface
func NewMemoizeMetrics ¶
func NewMemoizeMetrics(label string, reg *prometheus.Registry) MemoizeMetrics
NewMemoizeMetrics creates a MemoizeMetrics struct that records prometheus metrics that tracks activity in the memoize cache
type MetricsCache ¶
type MetricsCache struct {
// contains filtered or unexported fields
}
MetricsCache is a decorator for a Cache that uses prometheus to track read/write activity in the cache
func NewMetricsCache ¶
func NewMetricsCache(label string, reg prometheus.Registerer, next Cache) MetricsCache
NewMetricsCache creates a MetricsCache
func (MetricsCache) Delete ¶
func (c MetricsCache) Delete(ctx context.Context, key string) (err error)
Delete makes MetricsCache implement the Cache interface. It calls the decorated cache's delete method and uses a prometheus counter and histogram to track the number of calls and how long each call takes
func (MetricsCache) Get ¶
func (c MetricsCache) Get(ctx context.Context, key string, v interface{}) (err error)
Get makes MetricsCache implement the Cache interface. It calls the decorated cache's Get method and uses a prometheus counter and histogram to track the number of calls and how long a Get operation takes.
func (MetricsCache) HealthCheck ¶
func (c MetricsCache) HealthCheck(ctx context.Context) error
HealthCheck calls the decorated cache's HealthCheck method
func (MetricsCache) Keys ¶
Keys makes MetricsCache implement the Cache interface. It calls the decorated cache's Keys method and returns the results. It doesn't record any prometheus metrics.
func (MetricsCache) Set ¶
func (c MetricsCache) Set(ctx context.Context, key string, value interface{}) (err error)
Set makes MetricsCache implement the Cache interface. It calls the decorated cache's Set method and uses a prometheus counter and histogram to track the number of calls and how long a Set operation takes.
type Options ¶
type Options func(k *KeyValCache)
Options defines optional parameters for configuring a KeyValCache
func WithLocalCache ¶
func WithLocalCache(lc cache.LocalCache) Options
WithLocalCache lets you configure the LocalCache e.g. NewKeyValCache("localhost:6379", WithLocalCache(cache.NewTinyLFU(5000, 1 * time.Hour))
func WithMarshalFunc ¶
func WithMarshalFunc(marshalFunc cache.MarshalFunc) Options
WithMarshalFunc lets you set how data is marshaled into the cache
func WithUnmarshalFunc ¶
func WithUnmarshalFunc(unmarshalFunc cache.UnmarshalFunc) Options
WithUnmarshalFunc lets you set how data is unmarshaled from the cache
type Wrapper ¶
type Wrapper struct {
// contains filtered or unexported fields
}
Wrapper wraps a given cache with logic to store features and segments passed from the golang sdk it translates them from the sdk representation to our rest representation and buckets them per environment this means the proxy can store all the data from all sdk instances in one large cache but to each sdk it appears to have it's own unique cache
func NewWrapper ¶
NewWrapper creates a new Wrapper instance
func (*Wrapper) Keys ¶
func (wrapper *Wrapper) Keys() []interface{}
Keys returns a slice of the keys in the cache
func (*Wrapper) Purge ¶
func (wrapper *Wrapper) Purge()
Purge is used to completely clear the cache.