cache

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package cache provides a generic cache for ISUCON.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResetAll

func ResetAll()

ResetAll `NewCache()`で生成した全てのキャッシュをリセット

Types

type Cache

type Cache[K comparable, V any] struct {
	// contains filtered or unexported fields
}

Cache ジェネリックで、スレッドセーフなマップキャッシュ

sync.Mapのジェネリックなラッパーです

func New

func New[K comparable, V any]() *Cache[K, V]

New 新たなCacheを作成

func (*Cache[K, V]) Delete

func (c *Cache[K, V]) Delete(key K)

Delete 指定したKeyのキャッシュを削除

func (*Cache[K, V]) ForEach

func (c *Cache[K, V]) ForEach(f func(key K, value V) error) (err error)

ForEach キャッシュの全ての要素に対して処理を行う

func (*Cache[K, V]) Get

func (c *Cache[K, V]) Get(key K) (value V, ok bool)

Get 指定したKeyのキャッシュを取得

func (*Cache[K, V]) GetAndDelete

func (c *Cache[K, V]) GetAndDelete(key K) (value V, ok bool)

GetAndDelete 指定したKeyのキャッシュを取得して削除

func (*Cache[K, V]) Reset

func (c *Cache[K, V]) Reset()

Reset 全てのキャッシュを削除

func (*Cache[K, V]) Set

func (c *Cache[K, V]) Set(key K, value V)

Set 指定したKey-Valueのセットをキャッシュに入れる

Jump to

Keyboard shortcuts

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