kv

package
v0.30.2 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2025 License: MIT Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GetOptions

type GetOptions struct {
	CacheTTL int
}

GetOptions represents Cloudflare KV namespace get options.

type ListKey

type ListKey struct {
	Name string
	// Expiration is an expiration of KV value cache. The value `0` means no expiration.
	Expiration int
}

ListKey represents Cloudflare KV namespace list key.

type ListOptions

type ListOptions struct {
	Limit  int
	Prefix string
	Cursor string
}

ListOptions represents Cloudflare KV namespace list options.

type ListResult

type ListResult struct {
	Keys         []*ListKey
	ListComplete bool
	Cursor       string
}

ListResult represents Cloudflare KV namespace list result.

type Namespace

type Namespace struct {
	// contains filtered or unexported fields
}

Namespace represents interface of Cloudflare Worker's KV namespace instance.

func NewNamespace

func NewNamespace(varName string) (*Namespace, error)

NewNamespace returns Namespace for given variable name.

  • variable name must be defined in wrangler.toml as kv_namespace's binding.
  • if the given variable name doesn't exist on runtime context, returns error.
  • This function panics when a runtime context is not found.

func (*Namespace) Delete

func (ns *Namespace) Delete(key string) error

Delete deletes key-value pair specified by the key.

  • if a network error happens, returns error.

func (*Namespace) GetReader

func (ns *Namespace) GetReader(key string, opts *GetOptions) (io.Reader, error)

GetReader gets stream value by the specified key.

  • if a network error happens, returns error.

func (*Namespace) GetString

func (ns *Namespace) GetString(key string, opts *GetOptions) (string, error)

GetString gets string value by the specified key.

  • if a network error happens, returns error.

func (*Namespace) List

func (ns *Namespace) List(opts *ListOptions) (*ListResult, error)

List lists keys stored into the KV namespace.

func (*Namespace) PutReader

func (ns *Namespace) PutReader(key string, value io.Reader, opts *PutOptions) error

PutReader puts stream value into KV with key.

  • This method copies all bytes into memory for implementation restriction.
  • if a network error happens, returns error.

func (*Namespace) PutString

func (ns *Namespace) PutString(key string, value string, opts *PutOptions) error

PutString puts string value into KV with key.

  • if a network error happens, returns error.

type PutOptions

type PutOptions struct {
	Expiration    int
	ExpirationTTL int
}

PutOptions represents Cloudflare KV namespace put options.

Jump to

Keyboard shortcuts

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