cache

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2022 License: MIT Imports: 3 Imported by: 1

README

cache

cache是使用lru4算法实现的KV内存缓存组件,lru4是对lru算法进行淘汰策略变种产生的算法,使用较为简单。

example

  // See more in local_test.go
  key := []byte("k1")
  val := []byte("v1")
  cache := NewLocal()
  cache.Set(key,val)
  val = cache.Get(key)
  cache.Del(key)
  cache.FlushAll()

bench_mark

BenchmarkSet-4          10000000           223 ns/op
BenchmarkGet-4          20000000           113 ns/op
BenchmarkDel-4          20000000            76.6 ns/op
BenchmarkFlushAll-4     30000000            57.8 ns/op

Documentation

Overview

Package cache local cache

Package cache ...

Package cache defined local cache

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cacher

type Cacher interface {
	// Set defined cache_set
	Set(key, val []byte)
	// Get defined cache_get
	Get(key []byte) []byte
	// Del defined cache_delete by key
	Del(key []byte)
	// FlushAll defined flush all cache
	FlushAll()
}

Cacher interface

func NewLocal

func NewLocal() Cacher

NewLocal return local cache with default_cap=4096

Directories

Path Synopsis
Package lru4 ...
Package lru4 ...

Jump to

Keyboard shortcuts

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