lfu

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Core

type Core struct {
	eliminate.Core
	// contains filtered or unexported fields
}

Core is not safe under concurrent scene

func NewLFUCore

func NewLFUCore(opts ...Option) *Core

NewLFUCore will new a strategy object based on LFU algorithm

func (*Core) Add

func (c *Core) Add(key eliminate.Key, value eliminate.Value)

func (*Core) Clear

func (c *Core) Clear()

func (*Core) Get

func (c *Core) Get(key eliminate.Key) (eliminate.Value, bool)

func (*Core) Name

func (c *Core) Name() string

func (*Core) Remove

func (c *Core) Remove(key eliminate.Key)

func (*Core) RemoveLowFrequency

func (c *Core) RemoveLowFrequency()

type Option

type Option func(o *Options)

func WithEvictFunc

func WithEvictFunc(evict eliminate.EvictFunc) Option

WithEvictFunc define evict function execute when delete entity

func WithMaxSize

func WithMaxSize(size int) Option

WithMaxSize define max size of core

type Options

type Options struct {
	MaxSize   int
	OnEvicted eliminate.EvictFunc
}

Jump to

Keyboard shortcuts

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