Documentation ¶
Index ¶
- Constants
- type CacheTable
- func (h *CacheTable) BucketCapacity() int
- func (h *CacheTable) Capacity() int
- func (h *CacheTable) Delete(key string) (*Node, bool)
- func (h *CacheTable) Get(key string) (*Node, bool)
- func (h *CacheTable) Len() int
- func (h *CacheTable) Load() float32
- func (h *CacheTable) Set(key string, value interface{})
- type Node
Constants ¶
const MaxUint uint = 1<<bits.UintSize - 1
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacheTable ¶
type CacheTable struct {
// contains filtered or unexported fields
}
CacheTable implemented with a fixed bucketcapacity. removes oldest element in bucket once bucket reaches bucketcapacity
func NewCacheTable ¶
func NewCacheTable(numbuckets, bucketcapacity int, preallocatemem bool) (*CacheTable, error)
NewCacheTable is the constuctor that returns a new CacheTable of a fixed size returns an error when a size of 0 is provided
func (*CacheTable) BucketCapacity ¶
func (h *CacheTable) BucketCapacity() int
BucketCapacity returns the bucket size of the cachetable
func (*CacheTable) Capacity ¶
func (h *CacheTable) Capacity() int
Capacity returns the overall size of the cachetable
func (*CacheTable) Delete ¶
func (h *CacheTable) Delete(key string) (*Node, bool)
Delete the value associated with key in the cachetable
func (*CacheTable) Get ¶
func (h *CacheTable) Get(key string) (*Node, bool)
Get returns the value associated with a key in the cachetable, and an error indicating whether the value exists
func (*CacheTable) Len ¶
func (h *CacheTable) Len() int
Len returns the count of the elements in the cachetable
func (*CacheTable) Load ¶
func (h *CacheTable) Load() float32
Load returns the load factor of the cachetable
func (*CacheTable) Set ¶
func (h *CacheTable) Set(key string, value interface{})
Set the value for an associated key in the cachetable this always success as it will just overwrite the oldest element in the bucket