Documentation ¶
Index ¶
- type Consistenthash
- func (t *Consistenthash) Add(keys ...int64)
- func (t *Consistenthash) Del(key int64)
- func (t *Consistenthash) Get(value int64) (node int64, ok bool)
- func (t *Consistenthash) GetNextNodeStr(value string, step int) (nodes []int64, ok bool)
- func (t *Consistenthash) GetStr(value string) (node int64, ok bool)
- func (t *Consistenthash) Nodes() (_r []int64)
- type LimitHashMap
- type LimitMap
- type LinkedHashMap
- func (t *LinkedHashMap[K, V]) Back() (K, V, bool)
- func (t *LinkedHashMap[K, V]) Clear()
- func (t *LinkedHashMap[K, V]) Delete(k K)
- func (t *LinkedHashMap[K, V]) Front() (K, V, bool)
- func (t *LinkedHashMap[K, V]) Get(k K) (_r V, b bool)
- func (t *LinkedHashMap[K, V]) Iterator(front bool) *LinkedHashMapIterator[K, V]
- func (t *LinkedHashMap[K, V]) Len() int64
- func (t *LinkedHashMap[K, V]) LoadOrStore(k K, v V) (actual V, loaded bool)
- func (t *LinkedHashMap[K, V]) MoveToFront(k K)
- func (t *LinkedHashMap[K, V]) Put(k K, v V)
- type LinkedHashMapIterator
- type Map
- type MapL
- type TreeMap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Consistenthash ¶
type Consistenthash struct {
// contains filtered or unexported fields
}
func NewConsistenthash ¶
func NewConsistenthash(replicas int) (m *Consistenthash)
func (*Consistenthash) Add ¶
func (t *Consistenthash) Add(keys ...int64)
func (*Consistenthash) Del ¶
func (t *Consistenthash) Del(key int64)
func (*Consistenthash) GetNextNodeStr ¶
func (t *Consistenthash) GetNextNodeStr(value string, step int) (nodes []int64, ok bool)
func (*Consistenthash) Nodes ¶
func (t *Consistenthash) Nodes() (_r []int64)
type LimitHashMap ¶ added in v0.1.2
type LimitHashMap[K int | int64 | int8 | int16 | int32 | uint | uint64 | uint8 | uint16 | uint32 | float64 | float32 | uintptr | string, V any] struct { // contains filtered or unexported fields }
LimitHashMap is a capacity-limited hash map that supports different key types.
func NewLimitHashMap ¶ added in v0.1.2
func NewLimitHashMap[K int | int64 | int8 | int16 | int32 | uint | uint64 | uint8 | uint16 | uint32 | float64 | float32 | uintptr | string, V any](capacity int) *LimitHashMap[K, V]
NewLimitHashMap creates a new LimitHashMap with a specified capacity. Parameters:
capacity int - The total maximum capacity of the LimitHashMap.
Returns:
*LimitHashMap[K, V] - A new instance of a capacity-limited LimitHashMap.
func NewLimitHashMapWithSegment ¶ added in v0.1.2
func NewLimitHashMapWithSegment[K int | int64 | int8 | int16 | int32 | uint | uint64 | uint8 | uint16 | uint32 | float64 | float32 | uintptr | string, V any](capacity, segmentNumber int) *LimitHashMap[K, V]
NewLimitHashMapWithSegment creates a new LimitHashMap with a specified capacity and number of segments. Parameters:
capacity int - The total maximum capacity of the LimitHashMap. segmentNumber int - The number of segments to divide the cache into.
Returns:
*LimitHashMap[K, V] - A new instance of a capacity-limited LimitHashMap divided into segments.
func (*LimitHashMap[K, V]) Clear ¶ added in v0.1.2
func (c *LimitHashMap[K, V]) Clear()
func (*LimitHashMap[K, V]) Contains ¶ added in v0.1.2
func (c *LimitHashMap[K, V]) Contains(key K) bool
func (*LimitHashMap[K, V]) Del ¶ added in v0.1.2
func (c *LimitHashMap[K, V]) Del(key K)
func (*LimitHashMap[K, V]) Get ¶ added in v0.1.2
func (c *LimitHashMap[K, V]) Get(key K) (r V, b bool)
func (*LimitHashMap[K, V]) Len ¶ added in v0.1.2
func (c *LimitHashMap[K, V]) Len() int
func (*LimitHashMap[K, V]) Put ¶ added in v0.1.2
func (c *LimitHashMap[K, V]) Put(key K, value V) (prev V, b bool)
type LimitMap ¶
type LimitMap[K comparable, V any] struct { // contains filtered or unexported fields }
LimitMap represents a generic map with capacity limit
func NewLimitMap ¶
func NewLimitMap[K comparable, V any](capacity int) *LimitMap[K, V]
NewLimitMap creates a new instance of LimitMap with the given capacity
func (*LimitMap[K, V]) Del ¶ added in v0.1.4
func (mc *LimitMap[K, V]) Del(key K)
Del deletes a key-value pair from the map
func (*LimitMap[K, V]) RemoveMulti ¶ added in v0.1.2
func (mc *LimitMap[K, V]) RemoveMulti(keys []K)
RemoveMulti deletes multiple key-value pairs from the map
type LinkedHashMap ¶ added in v0.1.2
type LinkedHashMap[K, V any] struct { // contains filtered or unexported fields }
func NewLinkedHashMap ¶ added in v0.1.2
func NewLinkedHashMap[K, V any](limit int64) *LinkedHashMap[K, V]
func (*LinkedHashMap[K, V]) Back ¶ added in v0.1.2
func (t *LinkedHashMap[K, V]) Back() (K, V, bool)
func (*LinkedHashMap[K, V]) Clear ¶ added in v0.1.2
func (t *LinkedHashMap[K, V]) Clear()
func (*LinkedHashMap[K, V]) Delete ¶ added in v0.1.2
func (t *LinkedHashMap[K, V]) Delete(k K)
func (*LinkedHashMap[K, V]) Front ¶ added in v0.1.2
func (t *LinkedHashMap[K, V]) Front() (K, V, bool)
func (*LinkedHashMap[K, V]) Get ¶ added in v0.1.2
func (t *LinkedHashMap[K, V]) Get(k K) (_r V, b bool)
func (*LinkedHashMap[K, V]) Iterator ¶ added in v0.1.2
func (t *LinkedHashMap[K, V]) Iterator(front bool) *LinkedHashMapIterator[K, V]
func (*LinkedHashMap[K, V]) Len ¶ added in v0.1.2
func (t *LinkedHashMap[K, V]) Len() int64
func (*LinkedHashMap[K, V]) LoadOrStore ¶ added in v0.1.2
func (t *LinkedHashMap[K, V]) LoadOrStore(k K, v V) (actual V, loaded bool)
func (*LinkedHashMap[K, V]) MoveToFront ¶ added in v0.1.2
func (t *LinkedHashMap[K, V]) MoveToFront(k K)
func (*LinkedHashMap[K, V]) Put ¶ added in v0.1.2
func (t *LinkedHashMap[K, V]) Put(k K, v V)
type LinkedHashMapIterator ¶ added in v0.1.2
type LinkedHashMapIterator[K, V any] struct { // contains filtered or unexported fields }
func (*LinkedHashMapIterator[K, V]) Next ¶ added in v0.1.2
func (it *LinkedHashMapIterator[K, V]) Next() (K, V, bool)
type Map ¶
Map Define a generic synchronized map structure using sync.Map as the underlying data structure.
type MapL ¶
MapL Define a generic synchronized map structure that also keeps track of its length. It uses sync.Map as the underlying data structure and an int64 variable to count the number of elements.
type TreeMap ¶ added in v0.1.2
TreeMap Define the TreeMap structure which internally uses a B-tree for storing data with an RWMutex for concurrent access control.
func NewTreeMap ¶ added in v0.1.2
NewTreeMap Create a new instance of TreeMap with a specified degree for the underlying B-tree.
func (*TreeMap[K, V]) Ascend ¶ added in v0.1.2
Ascend Traverse all elements in ascending order based on their keys, executing the iterator function.
func (*TreeMap[K, V]) Del ¶ added in v0.1.4
func (m *TreeMap[K, V]) Del(key K)
Del Delete a key from the TreeMap.
func (*TreeMap[K, V]) Descend ¶ added in v0.1.2
Descend Traverse all elements in descending order based on their keys, executing the iterator function.