lru

package
v0.0.0-...-7567983 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Example
l := newLinkedList[int]()
e4 := l.pushBack(4)
e1 := l.pushFront(1)
l.insertBefore(3, e4)
l.insertAfter(2, e1)
for e, i := l.front(), 0; i < l.capacity; i++ {
	fmt.Println(e.Value)
	e = e.next
}
Output:

1
2
3
4

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

func NewCache

func NewCache(capacity int, options ...Option) *Cache

func (*Cache) DecrBy

func (c *Cache) DecrBy(ctx context.Context, key string, value int64) (int64, error)

func (*Cache) Delete

func (c *Cache) Delete(ctx context.Context, key ...string) (int64, error)

func (*Cache) Get

func (c *Cache) Get(ctx context.Context, key string) (val ecache.Value)

func (*Cache) GetSet

func (c *Cache) GetSet(ctx context.Context, key string, val string) (result ecache.Value)

func (*Cache) IncrBy

func (c *Cache) IncrBy(ctx context.Context, key string, value int64) (int64, error)

func (*Cache) IncrByFloat

func (c *Cache) IncrByFloat(ctx context.Context, key string, value float64) (float64, error)

func (*Cache) LPop

func (c *Cache) LPop(ctx context.Context, key string) (val ecache.Value)

func (*Cache) LPush

func (c *Cache) LPush(ctx context.Context, key string, val ...any) (int64, error)

func (*Cache) SAdd

func (c *Cache) SAdd(ctx context.Context, key string, members ...any) (int64, error)

func (*Cache) SRem

func (c *Cache) SRem(ctx context.Context, key string, members ...any) (int64, error)

func (*Cache) Set

func (c *Cache) Set(ctx context.Context, key string, val any, expiration time.Duration) error

func (*Cache) SetNX

func (c *Cache) SetNX(ctx context.Context, key string, val any, expiration time.Duration) (bool, error)

type EvictCallback

type EvictCallback func(key string, value any)

type Option

type Option func(l *Cache)

func WithCycleInterval

func WithCycleInterval(interval time.Duration) Option

func WithEvictCallback

func WithEvictCallback(callback func(k string, v any)) Option

Jump to

Keyboard shortcuts

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