per

package module
v0.0.0-...-3ddbace Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2021 License: MIT Imports: 5 Imported by: 0

README

per

optimal probabilistic cache stampede prevention.

reference

[1] https://cseweb.ucsd.edu//~avattani/papers/cache_stampede.pdf

[2] https://en.wikipedia.org/wiki/Cache_stampede

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Get(ctx context.Context, key string, ttl time.Duration, f ComputeFunc) (interface{}, error)
	SetItem(ctx context.Context, item Item, ttl time.Duration)
	BatchGetItems(ctx context.Context, keys []string) Items
	BatchSetItems(ctx context.Context, items Items, ttl time.Duration)
}

func New

func New() Cache

type ComputeFunc

type ComputeFunc func(ctx context.Context) (interface{}, error)

type Item

type Item struct {
	Key    string
	Value  interface{}
	Delta  time.Duration
	Expiry time.Time
}

func (*Item) Recompute

func (i *Item) Recompute(now time.Time) bool

type Items

type Items []*Item

func (Items) Interfaces

func (i Items) Interfaces() []interface{}

func (Items) Values

func (i Items) Values() []interface{}

Jump to

Keyboard shortcuts

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