storage

package
v0.0.0-...-961a5eb Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MapStorage

type MapStorage[T any] struct {
	// contains filtered or unexported fields
}

MapStorage can be used to store string keys and any type of value.

func (*MapStorage[T]) Delete

func (s *MapStorage[T]) Delete(key string) (v T, ok bool, err error)

Delete will delete the specified key and its associated value from storage. Returns true if the key existed (and was deleted) and false if the key did not exist. If deleting many elements from storage, the Shrink() function may be called afterwards to free up storage by reducing the size of the map.

func (*MapStorage[T]) Get

func (s *MapStorage[T]) Get(key string) (v T, ok bool, err error)

Get returns the value for the specified key.

func (*MapStorage[T]) Keys

func (s *MapStorage[T]) Keys() ([]string, error)

Keys returns a slice of all the keys in storage.

func (*MapStorage[T]) Set

func (s *MapStorage[T]) Set(key string, val T) error

Set will store the specified key/value combination.

func (*MapStorage[T]) Shrink

func (s *MapStorage[T]) Shrink()

Shrink will free up memory if many elements have been removed from the map. This function blocks and, depending on the amount of data stored, may take awhile to complete.

Jump to

Keyboard shortcuts

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