inmemcache

package module
v0.0.0-...-aa7da8c Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2018 License: MIT Imports: 3 Imported by: 0

README

inmemcache

inmemcache is an in-memory key:value store/cache similar to memcached that is suitable for applications running on a single machine. This may typically be used for testing applications that use memcache.

Under the hood, this library uses go get github.com/patrickmn/go-cache

Installation

go get github.com/davidbyttow/inmemcache

Usage
import (
  "github.com/bradfitz/gomemcache/memcache"
	"github.com/davidbyttow/inmemcache"
)

func main() {
	mc := inmemcache.New()
  mc.Set(&memcache.Item{Key: "foo", Value: []byte("my value")})

  it, err := mc.Get("foo")
  ...
}
Reference

godoc or https://godoc.org/github.com/bradfitz/gomemcache/memcache

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client implements a local in-memory cache version of memcache client

func New

func New() *Client

New returns an inmemcache Client that implements Client

func (*Client) Add

func (c *Client) Add(item *memcache.Item) error

Add according to bradfitz/gomemcache/memcache

func (*Client) CompareAndSwap

func (c *Client) CompareAndSwap(item *memcache.Item) error

CompareAndSwap according to bradfitz/gomemcache/memcache

func (*Client) Decrement

func (c *Client) Decrement(key string, delta uint64) (newValue uint64, err error)

Decrement according to bradfitz/gomemcache/memcache

func (*Client) Delete

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

Delete according to bradfitz/gomemcache/memcache

func (*Client) DeleteAll

func (c *Client) DeleteAll() error

DeleteAll according to bradfitz/gomemcache/memcache

func (*Client) FlushAll

func (c *Client) FlushAll() error

FlushAll according to bradfitz/gomemcache/memcache

func (*Client) Get

func (c *Client) Get(key string) (item *memcache.Item, err error)

Get according to bradfitz/gomemcache/memcache

func (*Client) GetMulti

func (c *Client) GetMulti(keys []string) (map[string]*memcache.Item, error)

GetMulti according to bradfitz/gomemcache/memcache

func (*Client) Increment

func (c *Client) Increment(key string, delta uint64) (newValue uint64, err error)

Increment according to bradfitz/gomemcache/memcache

func (*Client) Replace

func (c *Client) Replace(item *memcache.Item) error

Replace according to bradfitz/gomemcache/memcache

func (*Client) Set

func (c *Client) Set(item *memcache.Item) error

Set according to bradfitz/gomemcache/memcache

func (*Client) Touch

func (c *Client) Touch(key string, seconds int32) (err error)

Touch according to bradfitz/gomemcache/memcache

type MemcacheClient

type MemcacheClient interface {
	// Add according to bradfitz/gomemcache/memcache
	Add(item *memcache.Item) error
	// CompareAndSwap according to bradfitz/gomemcache/memcache
	CompareAndSwap(item *memcache.Item) error
	// Decrement according to bradfitz/gomemcache/memcache
	Decrement(key string, delta uint64) (newValue uint64, err error)
	// Delete according to bradfitz/gomemcache/memcache
	Delete(key string) error
	// DeleteAll according to bradfitz/gomemcache/memcache
	DeleteAll() error
	// FlushAll according to bradfitz/gomemcache/memcache
	FlushAll() error
	// Get according to bradfitz/gomemcache/memcache
	Get(key string) (item *memcache.Item, err error)
	// GetMulti according to bradfitz/gomemcache/memcache
	GetMulti(keys []string) (map[string]*memcache.Item, error)
	// Increment according to bradfitz/gomemcache/memcache
	Increment(key string, delta uint64) (newValue uint64, err error)
	// Replace according to bradfitz/gomemcache/memcache
	Replace(item *memcache.Item) error
	// Set according to bradfitz/gomemcache/memcache
	Set(item *memcache.Item) error
	// Touch according to bradfitz/gomemcache/memcache
	Touch(key string, seconds int32) (err error)
}

MemcacheClient is a useful helper and common interface for memcache client

Jump to

Keyboard shortcuts

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