memorystore

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseAll

func CloseAll() []exception.Exception

CloseAll MemoryStore connection

Types

type CacheItem

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

CacheItem wrap cache return object

func NewCacheItem

func NewCacheItem(key string, value []byte, expiration time.Duration) *CacheItem

NewCacheItem return new cache item object

func (*CacheItem) ExpiresIn

func (c *CacheItem) ExpiresIn() time.Duration

ExpiresIn contain expired information of cache object

func (*CacheItem) Key

func (c *CacheItem) Key() string

Key of cache object

func (*CacheItem) Value

func (c *CacheItem) Value() []byte

Value of cache object

type Config

type Config struct {
	Host string
	Port string
}

Config when fabricating memorystore connection

type Item

type Item interface {
	Key() string
	Value() []byte
	ExpiresIn() time.Duration
}

Item contain result got from MemoryStore interface

type Memcached

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

Memcached wrap memcache into cache interface

func AdaptMemcache

func AdaptMemcache(client MemcachedClient) *Memcached

AdaptMemcache adapt Cache interface

func (*Memcached) Get

func (m *Memcached) Get(ktx kontext.Context, key string) (Item, exception.Exception)

Get cache value

func (*Memcached) Set

func (m *Memcached) Set(ktx kontext.Context, key string, value []byte, expiration time.Duration) exception.Exception

Set cache value

type MemcachedClient

type MemcachedClient interface {
	Set(item *memcache.Item) error
	Get(key string) (item *memcache.Item, err error)
}

MemcachedClient wrap default memcache client

type MemoryStore

type MemoryStore interface {
	// To make it not expire set expiration into 0
	Set(ktx kontext.Context, key string, value []byte, expiration time.Duration) exception.Exception
	Get(ktx kontext.Context, key string) (Item, exception.Exception)
}

MemoryStore is interface to connect to cache infrastructure

func FabricateMemcached

func FabricateMemcached(instanceName string, config Config) MemoryStore

FabricateMemcached will fabricate memcached and wrap it into MemoryStore interface

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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