kv

package
v0.32.1 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package kv provides a generic thread-safe key-value store.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store[K comparable, V any] struct {
	// contains filtered or unexported fields
}

Store is a thread-safe generic key-value store.

func New

func New[K comparable, V any]() *Store[K, V]

New creates a new key-value store.

func (*Store[K, V]) Clear

func (s *Store[K, V]) Clear()

Clear removes all entries from the store.

func (*Store[K, V]) Delete

func (s *Store[K, V]) Delete(key K)

Delete removes a key from the store.

func (*Store[K, V]) Get

func (s *Store[K, V]) Get(key K) (V, bool)

Get retrieves a value by key.

func (*Store[K, V]) Keys

func (s *Store[K, V]) Keys() []K

Keys returns all keys in the store.

func (*Store[K, V]) Len

func (s *Store[K, V]) Len() int

Len returns the number of items in the store.

func (*Store[K, V]) Set

func (s *Store[K, V]) Set(key K, value V)

Set stores a value by key.

func (*Store[K, V]) SetBatch

func (s *Store[K, V]) SetBatch(items map[K]V)

SetBatch stores multiple key-value pairs at once.

Jump to

Keyboard shortcuts

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