memcache

package
v1.16.1 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package memcache provides a cache.Storage compatible client for the memcached cache server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Memcache

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

Memcache is a memcache client. It is safe for unlocked use by multiple concurrent goroutines.

func New

func New(ss []string, option Option) *Memcache

New returns a memcache client using the provided servers and options.

func NewWithClient added in v1.13.0

func NewWithClient(mc MemcacheClient, option Option) *Memcache

NewWithClient returns a memcache client given the client instance

func (*Memcache) Delete added in v1.2.0

func (c *Memcache) Delete(key string) error

Delete deletes the item for given key.

func (*Memcache) MaxIdleConns added in v1.10.0

func (c *Memcache) MaxIdleConns() int

MaxIdleConns returns client's cache MaxIdleConns option value.

func (*Memcache) Name

func (c *Memcache) Name() string

Name returns cache storage identifier.

func (*Memcache) Read

func (c *Memcache) Read(key string) ([]byte, error)

Read reads the item for given key. It's automatically decode item. Value depending on the client option.

func (*Memcache) ReadMulti

func (c *Memcache) ReadMulti(keys []string) (map[string][]byte, error)

ReadMulti is a batch version of Read. The returned map have exact length as provided keys. For cache miss, an empty byte will be returned.

func (*Memcache) Write

func (c *Memcache) Write(key string, value []byte, expiration time.Duration) error

Write writes the item for given key. It's automatically compress large item.

type MemcacheClient added in v1.13.0

type MemcacheClient interface {
	Set(*memcache.Item) error
	Get(string) (*memcache.Item, error)
	GetMulti([]string) (map[string]*memcache.Item, error)
	Delete(string) error
}

MemcacheClient provides interface of memcache.

type Option

type Option struct {
	Compress     bool
	Timeout      time.Duration
	MaxIdleConns int
	MaxAttempt   int
}

Option represents configurable configuration for memcache client.

Jump to

Keyboard shortcuts

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