cache

package module
v0.0.0-...-81951ae Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2020 License: BSD-3-Clause Imports: 3 Imported by: 2

README

cache

Package cache offers concurrency safe in-memory cache based on b-tree and hash-map indexing. All methods of Cache struct are concurrency safe and operates cache atomically.

Documentation

Overview

Package cache offers concurrency safe in-memory cache based on b-tree and hash-map indexing. All methods of Cache struct are concurrency safe and operates cache atomically.

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultDegree is default b-tree degree.
	DefaultDegree = 4
)

Functions

This section is empty.

Types

type Cache

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

Cache struct is concurrency safe in-memory cache based on b-tree and hash-map indexing. All methods of Cache struct are concurrency safe and operates cache atomically.

func NewCache

func NewCache() (ce *Cache)

NewCache returns a new Cache has default degree.

func NewCacheDegree

func NewCacheDegree(degree int) (ce *Cache)

NewCacheDegree returns a new Cache given degree.

func (*Cache) Close

func (ce *Cache) Close()

Close closes the cache. It must be called if the cache will not use.

func (*Cache) Del

func (ce *Cache) Del(key string)

Del deletes the key.

func (*Cache) Flush

func (ce *Cache) Flush()

Flush flushes the cache.

func (*Cache) Get

func (ce *Cache) Get(key string) (val interface{})

Get returns the value of given key. It returns nil, if the key wasn't exist.

func (*Cache) Set

func (ce *Cache) Set(key string, val interface{})

Set sets the value of given key. It deletes the key, if the val is nil.

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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