objcache

package
v1.13.12 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterNewGroupHook

func RegisterNewGroupHook(fn func(*Group))

RegisterNewGroupHook registers a hook that is run each time a group is created.

Types

type CacheStats

type CacheStats struct {
	Items int64
	Gets  int64
	Hits  int64
}

CacheStats are returned by stats accessors on Group.

type Context

type Context = interface{}

Context type.

type GetterFunc

type GetterFunc = func(ctx Context, key Key) (val Value, err error)

A GetterFunc implements Getter with a function.

type Group

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

A Group is a cache namespace and associated data loaded spread over a group of 1 or more machines.

func GetGroup

func GetGroup(name string) *Group

GetGroup returns the named group previously created with NewGroup, or nil if there's no such group.

func NewGroup

func NewGroup(name string, cacheNum int, getter GetterFunc, onEvicted ...OnEvictedFunc) *Group

NewGroup creates a coordinated group-aware Getter from a Getter.

The returned Getter tries (but does not guarantee) to run only one Get call at once for a given key across an entire set of peer processes. Concurrent callers both in the local process and in other processes receive copies of the answer once the original Get completes.

The group name must be unique for each getter.

func (*Group) CacheStats

func (g *Group) CacheStats() CacheStats

CacheStats returns stats about the provided cache within the group.

func (*Group) Get

func (g *Group) Get(ctx Context, key Key) (val Value, err error)

Get func.

func (*Group) Name

func (g *Group) Name() string

Name returns the name of the group.

func (*Group) TryGet

func (g *Group) TryGet(key Key) (val Value, ok bool)

TryGet func.

type Key

type Key = lru.Key

Key type.

type OnEvictedFunc

type OnEvictedFunc = func(key Key, value Value)

OnEvictedFunc func.

type Value

type Value = interface{}

Value type.

Directories

Path Synopsis
Package lru implements an LRU cache.
Package lru implements an LRU cache.

Jump to

Keyboard shortcuts

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