Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache[T hashable, J any] struct { // Touch resets the cache expire time for an item to keep this value longer Touch func(key T) // Get returns the value of an item Get func(key T) (J, bool) // Set will either create a new value, or overwrite an existing one Set func(key T, value J) // Del will remove an item from the cache Del func(key T) // TTL will change the time to live for cache items before they expire // you can optionally change the delInterval for how often the cache will check to auto delete expired items TTL func(ttl time.Duration, delInterval ...time.Duration) // ForEach runs a function for each cache item in the list ForEach func(lambda func(key T, value J)) // ForEachBreak is like ForEach, but will allow you to break the loop early // return `true` to continue the loop // return `false` to break the loop ForEachBreak func(lambda func(key T, value J) bool) // Len returns the number of cache items that have not expired Len func() uintptr // LenMap returns the number of cache items including those that have expired MapLen func() uintptr // Fillrate returns the fill rate of the map as a percentage integer // this method runs the direct function form haxmap https://github.com/alphadose/haxmap Fillrate func() uintptr // Grow resizes the hashmap to a new size, gets rounded up to next power of 2 To double the size of the hashmap use newSize 0 This function returns immediately, the resize operation is done in a goroutine No resizing is done in case of another resize operation already being in progress Growth and map bucket policy is inspired from https://github.com/cornelk/hashmap // this method runs the direct function form haxmap https://github.com/alphadose/haxmap Grow func(newSize uintptr) // ClearExpired clears the expired items from the cache // this function will automatically run on an interval unless you disable it ClearExpired func() // ClearEarly allows you to clear cache items before they expire // optionally set the `ttl` param to a time, and only items older than that time will be deleted ClearEarly func(ttl ...time.Duration) // contains filtered or unexported fields }
Click to show internal directories.
Click to hide internal directories.