Documentation ¶
Index ¶
- type ConnSet
- type FIFOCache
- func (c *FIFOCache) Exist(k interface{}) bool
- func (c *FIFOCache) Get(k interface{}) interface{}
- func (c *FIFOCache) OnRemove(f func(k, v interface{}))
- func (c *FIFOCache) Put(k, v interface{})
- func (c *FIFOCache) PutIfNotExist(k, v interface{}) bool
- func (c *FIFOCache) Remove(k interface{}) bool
- func (c *FIFOCache) Reset()
- func (c *FIFOCache) Size() int
- type FixedCapDurationCache
- func (fdc *FixedCapDurationCache) Add(key string, v interface{})
- func (fdc *FixedCapDurationCache) AddIfNotExist(key string, v interface{}) bool
- func (fdc *FixedCapDurationCache) Diff(keyList []string) []interface{}
- func (fdc *FixedCapDurationCache) ExistsByKey(key string) bool
- func (fdc *FixedCapDurationCache) GetAll() []interface{}
- func (fdc *FixedCapDurationCache) GetByKey(key string) interface{}
- func (fdc *FixedCapDurationCache) Length() int
- type Interval
- type IntervalSet
- type LoadPeerIdFromCMTlsCertFunc
- type PeerIdSet
- type Set
- type StringSet
- type Uint64Set
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FIFOCache ¶
type FIFOCache struct {
// contains filtered or unexported fields
}
FIFOCache is a cache with FIFO elimination strategy.
func NewFIFOCache ¶
NewFIFOCache create a new FIFOCache. The cap is the max entry size for cache. The threadSafe set whether all operations bind a lock.
func (*FIFOCache) Get ¶
func (c *FIFOCache) Get(k interface{}) interface{}
Get a value with key given. If not exist, return nil.
func (*FIFOCache) OnRemove ¶
func (c *FIFOCache) OnRemove(f func(k, v interface{}))
OnRemove register a call back function, it will be invoked when entry eliminating or removing.
func (*FIFOCache) PutIfNotExist ¶
PutIfNotExist will put a key-value pair to cache if the key not exist in cache, then return true. If not put, return false.
type FixedCapDurationCache ¶
type FixedCapDurationCache struct {
// contains filtered or unexported fields
}
FixedCapDurationCache cache data with fixed capacity and duration from [now - duration,now]
func NewFixedCapDurationCache ¶
func NewFixedCapDurationCache(duration time.Duration, capacity int) *FixedCapDurationCache
NewFixedCapDurationCache new cache instance
func (*FixedCapDurationCache) Add ¶
func (fdc *FixedCapDurationCache) Add(key string, v interface{})
Add data to cache
func (*FixedCapDurationCache) AddIfNotExist ¶
func (fdc *FixedCapDurationCache) AddIfNotExist(key string, v interface{}) bool
AddIfNotExist add data to cache is key not exists
func (*FixedCapDurationCache) Diff ¶
func (fdc *FixedCapDurationCache) Diff(keyList []string) []interface{}
Diff return cache data not exists in key list
func (*FixedCapDurationCache) ExistsByKey ¶
func (fdc *FixedCapDurationCache) ExistsByKey(key string) bool
ExistsByKey if key in cache and not expire return ture, else return false
func (*FixedCapDurationCache) GetAll ¶
func (fdc *FixedCapDurationCache) GetAll() []interface{}
GetAll get not expire value in cache
func (*FixedCapDurationCache) GetByKey ¶
func (fdc *FixedCapDurationCache) GetByKey(key string) interface{}
GetByKey if key in cache and not expire return value, else return nil
func (*FixedCapDurationCache) Length ¶
func (fdc *FixedCapDurationCache) Length() int
Length return cache data count
type Interval ¶
type Interval struct {
// contains filtered or unexported fields
}
Interval such as: [2,3],[5,9]
type IntervalSet ¶
type IntervalSet struct {
// contains filtered or unexported fields
}
IntervalSet is a set of Interval.
func NewIntervalSet ¶
func NewIntervalSet() *IntervalSet
NewIntervalSet create a new IntervalSet instance.
func (*IntervalSet) Contains ¶
func (is *IntervalSet) Contains(index uint64) bool
Contains return whether number in IntervalSet.
func (*IntervalSet) MissingCount ¶
func (is *IntervalSet) MissingCount() int
MissingCount return the count of numbers than not record in IntervalSet from 1 to max number.
func (*IntervalSet) RemoveBefore ¶
func (is *IntervalSet) RemoveBefore(removeIntervalEnd uint64)
RemoveBefore remove Interval before removeIntervalEnd
func (*IntervalSet) String ¶
func (is *IntervalSet) String() string
String return all Interval in IntervalSet.
type LoadPeerIdFromCMTlsCertFunc ¶
type LoadPeerIdFromCMTlsCertFunc func([]*cmx509.Certificate) (peer.ID, error)
LoadPeerIdFromCMTlsCertFunc is a function can load the peer.ID from []*cmx509.Certificate exchanged during tls handshaking.