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: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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
⌂ 换网址