kvstore

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2025 License: Apache-2.0, BSD-3-Clause Imports: 4 Imported by: 1

Documentation

Overview

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.

Index

Constants

This section is empty.

Variables

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")

	// ErrTooManyRequests is returned when inserting a value exceeds the
	// rate limit.
	ErrTooManyRequests = errors.New("kvstore: too many requests")

	// ErrInvalidOptions indicates the options provided for this operation were invalid.
	ErrInvalidOptions = errors.New("kvstore: invalid options")

	// ErrBadRequest indicates the KV Store request was bad.
	ErrBadRequest = errors.New("kvstore: bad request")

	// ErrPreconditionFailed indicates a precondition for the kvstore operation failed.
	ErrPreconditionFailed = errors.New("kvstore: precondition failed")

	// ErrPayloadTooLarge indicates the item exceeded the payload limit.
	ErrPayloadTooLarge = errors.New("kvstore: payload too large")

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

Functions

This section is empty.

Types

type Entry

type Entry struct {
	io.Reader
	// 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) Generation added in v1.4.0

func (e *Entry) Generation() uint64

func (*Entry) Meta added in v1.4.0

func (e *Entry) Meta() []byte

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) Delete added in v1.3.1

func (s *Store) Delete(key string) error

Delete removes a key from the associated 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