example

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Code generated by github.com/Hartimer/loadingcache/cmd/typedcache, DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CoolCache

type CoolCache interface {
	Get(key Name) (int64, error)
	Put(key Name, value int64)
	Invalidate(key Name, keys ...Name)
	InvalidateAll()
}

func NewCoolCache

func NewCoolCache(options CoolCacheOptions) CoolCache

type CoolCacheOptions

type CoolCacheOptions struct {
	Clock            clock.Clock
	ExpireAfterWrite time.Duration
	ExpireAfterRead  time.Duration
	Load             LoadFunc
	MaxSize          int32
	RemovalListeners []RemovalListener
	ShardCount       int
	HashCodeFunc     func(key Name) int
}

type Example

type Example struct {
	// contains filtered or unexported fields
}

Example demonstrates using a strongly typed cache

func New

func New() *Example

New returns a new instance of the example

func (*Example) AddAges

func (e *Example) AddAges(names ...Name) int64

AddAges returns the sum of ages identified by names

func (*Example) Set

func (e *Example) Set(name Name, age int64)

Set sents an entry in the cache

type LoadFunc

type LoadFunc func(Name) (int64, error)

type Name

type Name string

Name just represents a deeper type

type RemovalListener

type RemovalListener func(RemovalNotification)

type RemovalNotification

type RemovalNotification struct {
	Key    Name
	Value  int64
	Reason loadingcache.RemovalReason
}

Jump to

Keyboard shortcuts

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