go_cache

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

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

Go to latest
Published: Jun 19, 2020 License: MIT Imports: 23 Imported by: 0

README

  • 分片syncMap
  • heap管理过期key
  • 缓存策略
    • FIFO
  • web接口
  • 缓存client

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPrivateKey

func GetPrivateKey(priKeyPath string) (*rsa.PrivateKey, error)

func GetPublicKey

func GetPublicKey(publicKeyPath string) (publicKey *rsa.PublicKey, err error)

func Json

func Json(obj interface{}) []byte

func NewCacheElimination

func NewCacheElimination(mode uint8) cacheMode.CacheElimination

func NewRoundQueue

func NewRoundQueue(cap uint64) *roundQueue

Types

type ApiResponse

type ApiResponse struct {
	Msg  string `json:"err,omitempty"`
	Data string `json:"data,omitempty"`
	Code int    `json:"code,omitempty"`
}

type CacheManager

type CacheManager interface {
	MapPut(key, value string, expiryPolicy int64) error // set key value
	MapLoad(key string) (string, bool)                  // get value
	MapRemove(key string)                               // remove

	Clear()
	Close()
}

func NewManager

func NewManager(MaxMemCap uint64, shardSize uintptr, mode uint8) CacheManager

type Client

type Client interface {
	MapPut(key, value string, expiryPolicy int64) error // set key value
	MapLoad(key string) (string, bool, error)           // get value
	MapRemove(key string) (bool, error)                 // remove

	PingUpstreamService() // ping 上游服务器

	Close() // 释放资源
}

func NewClient

func NewClient(nodes []*consistent_hashing.Node, PublicKeyPath string) (Client, error)

type Manager

type Manager struct {
	Push chan<- *cacheMode.Entry
	Pop  <-chan *cacheMode.Entry
	// contains filtered or unexported fields
}

func (*Manager) Clear

func (m *Manager) Clear()

func (*Manager) Close

func (m *Manager) Close()

func (*Manager) MapLoad

func (m *Manager) MapLoad(key string) (value string, ok bool)

func (*Manager) MapPut

func (m *Manager) MapPut(key, value string, expiryPolicy int64) error

func (*Manager) MapRemove

func (m *Manager) MapRemove(key string)

func (*Manager) WatchPopChan

func (m *Manager) WatchPopChan()

type RoundQueue

type RoundQueue interface {
	Insert(uint32)
	Pop() uint32
	Growing()
	IsEmpty() bool
}

Jump to

Keyboard shortcuts

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