memerycache

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	B  = 1 << (iota * 10) // 1
	KB                    // 1024
	MB                    // 1048576
	GB                    // 1073741824
	TB                    // 1099511627776
	PB                    // 1125899906842624
)

Variables

This section is empty.

Functions

func CalculateSize

func CalculateSize(val interface{}) int64

func CovertSize

func CovertSize(size string, defaultMemorySize int64) (int64, string)

Types

type Cache

type Cache interface {
	SetMaxMemory(size string) bool
	Set(key string, val interface{}, expire time.Duration) bool
	Get(key string) (interface{}, bool)
	Del(key string) bool
	Exists(key string) bool
	Flush() bool
	Keys() int64
}

func NewMemCache

func NewMemCache() Cache

type CacheImpl

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

func NewCache

func NewCache() *CacheImpl

func (*CacheImpl) Del

func (c *CacheImpl) Del(key string) bool

func (*CacheImpl) Exists

func (c *CacheImpl) Exists(key string) bool

func (*CacheImpl) Flush

func (c *CacheImpl) Flush() bool

func (*CacheImpl) Get

func (c *CacheImpl) Get(key string) (interface{}, bool)

func (*CacheImpl) Keys

func (c *CacheImpl) Keys() int64

func (*CacheImpl) Set

func (c *CacheImpl) Set(key string, val interface{}, expire ...time.Duration) bool

func (*CacheImpl) SetMaxMemory

func (c *CacheImpl) SetMaxMemory(size string) bool

type MemoryCache

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

func (*MemoryCache) Del

func (m *MemoryCache) Del(key string) bool

func (*MemoryCache) Exists

func (m *MemoryCache) Exists(key string) bool

func (*MemoryCache) Flush

func (m *MemoryCache) Flush() bool

func (*MemoryCache) Get

func (m *MemoryCache) Get(key string) (interface{}, bool)

func (*MemoryCache) Keys

func (m *MemoryCache) Keys() int64

func (*MemoryCache) Set

func (m *MemoryCache) Set(key string, val interface{}, expire time.Duration) bool

func (*MemoryCache) SetMaxMemory

func (m *MemoryCache) SetMaxMemory(size string) bool

SetMaxMemory size: 1KB 100KB 1MB 100MB 1GB default 100MB

Jump to

Keyboard shortcuts

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