memcached

package
v0.0.0-...-e954c25 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2017 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Wrapper for Memcached

Index

Constants

View Source
const (
	NothingFlag        uint32 = 0
	SnappyCompressFlag uint32 = 1
	GzipCompressFlag   uint32 = 2
)

Variables

View Source
var (

	// Predefined expiration time
	NoExpiration  = 0
	Expiration15m = int32((15 * time.Minute).Seconds())
	Expiration1h  = int32((time.Hour).Seconds())
	Expiration24h = int32((24 * time.Hour).Seconds())
	Expiration3d  = int32((3 * 24 * time.Hour).Seconds())
	Expiration30d = int32((30 * 24 * time.Hour).Seconds())
)

Functions

func Delete

func Delete(key string) error

Delete removes item form a cache

func GetBytes

func GetBytes(key string) ([]byte, bool, error)

func GetFloat

func GetFloat(key string) (float64, bool, error)

func GetInt

func GetInt(key string) (int, bool, error)

func GetObj

func GetObj(key string, dest interface{}) (bool, error)

GetObj decodes object to dest pointer Returns false if not exists or error

func GetSetBool

func GetSetBool(key string, getFn func() (bool, error), expire int32, flag ...uint32) (bool, error)

func GetSetInt

func GetSetInt(key string, getFn func() (int, error), expire int32, flag ...uint32) (int, error)

func GetSetObj

func GetSetObj(key string, dest interface{}, getFn func() (interface{}, error), expire int32, flag ...uint32) error

GetSetObj gets object from cache and save it to dest pointer. If object not exists, get it from getFn and save to a cache.

func GetSetString

func GetSetString(key string, getFn func() (string, error), expire int32, flag ...uint32) (string, error)

func GetString

func GetString(key string) (string, bool, error)

Returns: value, exists, error

func SetBytes

func SetBytes(key string, value []byte, expire int32, flag ...uint32) error

func SetExpiration

func SetExpiration(dur time.Duration) int32

Using when need expiration > 30d

func SetFloat

func SetFloat(key string, value float64, expire int32, flag ...uint32) error

func SetInt

func SetInt(key string, value int, expire int32, flag ...uint32) error

func SetObj

func SetObj(key string, obj interface{}, expire int32, flag ...uint32) error

func SetString

func SetString(key, value string, expire int32, flag ...uint32) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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