memcache

package
v0.0.0-...-5af5632 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package memcache provides a minimally compatible interface for google.golang.org/appengine/memcache and stores the data in Redis (e.g., via Cloud Memorystore).

Index

Constants

This section is empty.

Variables

View Source
var (
	Gob  = Codec{gobMarshal, gobUnmarshal}
	JSON = Codec{json.Marshal, json.Unmarshal}
)
View Source
var ErrCacheMiss = errors.New("memcache: cache miss")

Functions

This section is empty.

Types

type Client

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

func New

func New(addr string) *Client

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, key string) error

func (*Client) Get

func (c *Client) Get(ctx context.Context, key string) ([]byte, error)

Get gets the item.

func (*Client) Set

func (c *Client) Set(ctx context.Context, item *Item) error

func (*Client) WithCodec

func (c *Client) WithCodec(codec Codec) *CodecClient

type Codec

type Codec struct {
	Marshal   func(interface{}) ([]byte, error)
	Unmarshal func([]byte, interface{}) error
}

type CodecClient

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

func (*CodecClient) Delete

func (c *CodecClient) Delete(ctx context.Context, key string) error

func (*CodecClient) Get

func (c *CodecClient) Get(ctx context.Context, key string, v interface{}) error

func (*CodecClient) Set

func (c *CodecClient) Set(ctx context.Context, item *Item) error

type Item

type Item struct {
	Key        string
	Value      []byte
	Object     interface{}   // Used with Codec.
	Expiration time.Duration // Read-only.
}

Jump to

Keyboard shortcuts

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