Documentation
¶
Overview ¶
Package cache implements a simple in-memory cache.
Example ¶
package main
import (
"fmt"
"gitee.com/erdian718/cache"
)
func main() {
c := cache.New[string, int](1024)
c.Store("A", 1)
c.Store("B", 2)
fmt.Println(c.Load("A"))
fmt.Println(c.Load("B"))
fmt.Println(c.Load("C"))
}
Output: 1 true 2 true 0 false
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Map ¶
type Map[K comparable, V any] struct { // contains filtered or unexported fields }
Map represents a in-memory cache map.
func New ¶
func New[K comparable, V any](cap int) *Map[K, V]
New creates a new in-memory cache map by capacity.
func (*Map[K, V]) Clear ¶ added in v0.4.0
func (m *Map[K, V]) Clear()
Clear deletes all the entries, resulting in an empty Map.
Click to show internal directories.
Click to hide internal directories.