Documentation ¶
Index ¶
- Variables
- type CacheItem
- type CacheShard
- type Config
- type Hasher
- type PriorityQueue
- func (pq PriorityQueue) Len() int
- func (pq PriorityQueue) Less(i, j int) bool
- func (pq *PriorityQueue) Pop() interface{}
- func (pq *PriorityQueue) PopItem() (*CacheItem, error)
- func (pq *PriorityQueue) Push(item interface{})
- func (pq *PriorityQueue) PushItem(item *CacheItem)
- func (pq PriorityQueue) Swap(i, j int)
- func (pq PriorityQueue) TopItem() (*CacheItem, error)
- type SaCache
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type CacheItem ¶
type CacheItem struct {
// contains filtered or unexported fields
}
CacheItem is the item inside of cache table.
func (*CacheItem) ExpireTime ¶
ExpireTime returns expire time of cache item.
type CacheShard ¶
type CacheShard struct {
// contains filtered or unexported fields
}
type Config ¶
type Config struct { // time duration for removing expired items. CleanDuration time.Duration // shards ShardNumber int // Hasher Hasher Hasher }
func DefaultConfig ¶
func DefaultConfig() Config
type PriorityQueue ¶
type PriorityQueue []*CacheItem
func (PriorityQueue) Len ¶
func (pq PriorityQueue) Len() int
Len returns the number of elements of queue.
func (PriorityQueue) Less ¶
func (pq PriorityQueue) Less(i, j int) bool
Less is comparetor for expire time
func (*PriorityQueue) Pop ¶
func (pq *PriorityQueue) Pop() interface{}
Pop pop the front of queue or nil when queue is empty.
func (*PriorityQueue) PopItem ¶
func (pq *PriorityQueue) PopItem() (*CacheItem, error)
Pop item from pq and auto re-adjust
func (*PriorityQueue) Push ¶
func (pq *PriorityQueue) Push(item interface{})
Push push a pointer of cache item.
func (*PriorityQueue) PushItem ¶
func (pq *PriorityQueue) PushItem(item *CacheItem)
Push item to pq and auto re-adjust
func (PriorityQueue) TopItem ¶
func (pq PriorityQueue) TopItem() (*CacheItem, error)
Front returns the front element or nil when queue is empty.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.