faststructcache

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2023 License: MIT Imports: 3 Imported by: 0

README

faststructcache

import "github.com/andys/faststructcache"

Index

type FastStructCache

FastStructCache is an in-memory key-value store intended to be able to store larger structs (although any data type should work). It wraps fastcache from VictoriaMetrics with the binary codec from kelindar, and optional snappy-like compression (S2 from klauspost).

type FastStructCache[KT, VT any] struct {
    Cache *fastcache.Cache
    // contains filtered or unexported fields
}
func New
func New[KT, VT any](mb int, compress bool) FastStructCache[KT, VT]

New returns new cache with the given maxBytes capacity in bytes (min 32MB), with optional light compression.

func (FastStructCache[KT, VT]) Del
func (c FastStructCache[KT, VT]) Del(k KT)

Del deletes value for the given k from the cache.

func (FastStructCache[KT, VT]) Get
func (c FastStructCache[KT, VT]) Get(k KT) *VT

Get returns pointer to a value stored for given key k, or nil if it didn't exist in the cache

func (FastStructCache[KT, VT]) Has
func (c FastStructCache[KT, VT]) Has(k KT) bool

Has returns true if entry for the given key k exists in the cache.

func (FastStructCache[KT, VT]) Reset
func (c FastStructCache[KT, VT]) Reset()

Reset removes all the items from the cache.

func (FastStructCache[KT, VT]) Set
func (c FastStructCache[KT, VT]) Set(k KT, v VT)

Set stores (k, v) in the cache.

Generated by gomarkdoc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FastStructCache

type FastStructCache[KT, VT any] struct {
	Cache *fastcache.Cache
	// contains filtered or unexported fields
}

FastStructCache is an in-memory key-value store intended to be able to store larger structs (although any data type should work). It wraps fastcache from VictoriaMetrics with the binary codec from kelindar, and optional snappy-like compression (S2 from klauspost).

func New

func New[KT, VT any](mb int, compress bool) FastStructCache[KT, VT]

New returns new cache with the given maxBytes capacity in bytes (min 32MB), with optional light compression.

func (FastStructCache[KT, VT]) Del

func (c FastStructCache[KT, VT]) Del(k KT)

Del deletes value for the given k from the cache.

func (FastStructCache[KT, VT]) Get

func (c FastStructCache[KT, VT]) Get(k KT) *VT

Get returns pointer to a value stored for given key k, or nil if it didn't exist in the cache

func (FastStructCache[KT, VT]) Has

func (c FastStructCache[KT, VT]) Has(k KT) bool

Has returns true if entry for the given key k exists in the cache.

func (FastStructCache[KT, VT]) Reset

func (c FastStructCache[KT, VT]) Reset()

Reset removes all the items from the cache.

func (FastStructCache[KT, VT]) Set

func (c FastStructCache[KT, VT]) Set(k KT, v VT)

Set stores (k, v) in the cache.

Jump to

Keyboard shortcuts

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