Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cacheable ¶
type Cacheable interface { encoding.BinaryMarshaler encoding.BinaryUnmarshaler }
Cacheable is an interface used to describe values (and keys) that can be stored within a cache/stash; this generally means that any value provided to the cache/stash MUST be serializable
type EvictionPolicy ¶
type EvictionPolicy string
EvictionPolicy is a typed string used to describe the configured eviction policy for a given Stasher
const ( LeastRecentlyUsed EvictionPolicy = "least_recently_used" LeastFrequentlyUsed EvictionPolicy = "least_frequently_used" FirstInFirstOut EvictionPolicy = "first_in_first_out" )
type Example ¶
type Example struct { Int int `json:"int,omitempty"` Float float64 `json:"float,omitempty"` String string `json:"string,omitempty"` }
Example is a type that can be used for simple tests or to understand how to make a struct Cacheable KIM: although we use JSON for simple serialization you can use whatever works like YAML, protobuf etc.
func ExampleGenFloat64 ¶
ExampleGenFloat64 will generate a random number of random float values if n is equal to 0 not to exceed the constant TestMaxExamples, if n is provided, it will generate that many items
func (*Example) MarshalBinary ¶
func (*Example) UnmarshalBinary ¶
type Stasher ¶
type Stasher interface { //Write can be used to create/update a value in the cache with the given // key. If the value exists, replaced will be true Write(key interface{}, value Cacheable) (replaced bool, err error) //Read can be used to read a value in the cache with the given key // if the value exists, it will be unmarshalled into the Cacheable // pointer; this is expected to work very much like an Unmarshal // function. If a value isn't found with the given key, an error // will be returned Read(key interface{}, v Cacheable) (err error) //Delete can be used to remove a value from the cache with a given // key. If the value isn't found, an error is returned. //KIM: this function doesn't return the value by design; why would // you need to read the value if you're deleting it? Delete(key interface{}) (err error) }
Stasher is an interface used to read and write data to a cache/stash KIM: Although key is an interface, if that interface doesn't contain something that is serializable, other concrete implementations won't work.