hotspotcache

package module
v0.0.0-...-64ae194 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2019 License: BSD-3-Clause Imports: 5 Imported by: 0

README

go.hotspotcache

Build Status GoDoc Coverage Status Go Report

Package hotspotcache stores values like sync.Map does.

Meanwhile, it handles a aging queue: every access to a existing object in the cache, it will be lifted up to he top of the queue and marked as the newest element. When the size in cache exceeds preset limit size, the bottom elements of the queue would be removed.

Documentation

Overview

Package hotspotcache stores values like sync.Map does. Meanwhile, it handles a aging queue: every access to a existing object in the cache, it will be lifted up to he top of the queue and marked as the newest element. When the size in cache exceeds preset limit size, the bottom elements of the queue would be removed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache is the hotspot cache object.

func New

func New(maxSize int) *Cache

New returns a initialized cache with given size. When size of the cache exceeds maxSize, it will start cleaning.

func (*Cache) Load

func (c *Cache) Load(key interface{}) (value interface{}, exist bool)

Load read a value in the cache. If value does not exist in cache, the return exist will be false, otherwise true. If value exists, its hotspot will also be risen to the top.

func (*Cache) MaxSize

func (c *Cache) MaxSize() int

MaxSize returns the max size of this cache

func (*Cache) Store

func (c *Cache) Store(key, value interface{})

Store saves a value by corresponding key.

Jump to

Keyboard shortcuts

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