v1.3.0 Latest Latest

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

Go to latest
Published: Feb 21, 2024 License: Apache-2.0, BSD-3-Clause Imports: 4 Imported by: 0



Package kvstore provides access to Fastly KV stores.

KV stores provide durable storage of key/value data that is readable and writable at the edge and synchronized globally.

See the Fastly KV store documentation for details.



This section is empty.


View Source
var (
	// ErrStoreNotFound indicates that the named store doesn't exist.
	ErrStoreNotFound = errors.New("kvstore: store not found")

	// ErrKeyNotFound indicates that the named key doesn't exist in this
	// KV store.
	ErrKeyNotFound = errors.New("kvstore: key not found")

	// ErrInvalidKey indicates that the given key is invalid.
	ErrInvalidKey = errors.New("kvstore: invalid key")

	// ErrUnexpected indicates than an unexpected error occurred.
	ErrUnexpected = errors.New("kvstore: unexpected error")


This section is empty.


type Entry

type Entry struct {
	// contains filtered or unexported fields

Entry represents a KV store value.

It embeds an io.Reader which holds the contents of the value, and can be passed to functions that accept an io.Reader.

For smaller values, an Entry.String method is provided to consume the contents of the underlying reader and return a string.

Do not mix-and-match these approaches: use either the io.Reader or the Entry.String method, not both.

func (*Entry) String

func (e *Entry) String() string

String consumes the entire contents of the Entry and returns it as a string.

Take care when using this method, as large values might exceed the per-request memory limit.

type Store

type Store struct {
	// contains filtered or unexported fields

Store represents a Fastly KV store

func Open

func Open(name string) (*Store, error)

Open returns a handle to the named kv store

func (*Store) Insert

func (s *Store) Insert(key string, value io.Reader) error

Insert adds a key to the associated KV store.

func (*Store) Lookup

func (s *Store) Lookup(key string) (*Entry, error)

Lookup fetches a key from the associated KV store. If the key does not exist, Lookup returns the sentinel error ErrKeyNotFound.

Jump to

Keyboard shortcuts

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