Documentation ¶
Index ¶
- type ConnSet
- type ExpireCache
- func (ec *ExpireCache) Cap() int
- func (ec *ExpireCache) ExistsByKey(key string) bool
- func (ec *ExpireCache) GetAll() []interface{}
- func (ec *ExpireCache) GetByKey(key string) interface{}
- func (ec *ExpireCache) IsFull() bool
- func (ec *ExpireCache) Put(key string, v interface{}) bool
- func (ec *ExpireCache) RemoveExpired()
- func (ec *ExpireCache) Size() int
- 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 Node
- 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 ConnSet ¶
type ConnSet struct {
// contains filtered or unexported fields
}
ConnSet Connection set only store data of type network.Conn
func (*ConnSet) Exist ¶
Exist determine whether the specified data exists
func (*ConnSet) Range ¶
Range iterate over the data in the collection
type ExpireCache ¶ added in v1.3.0
type ExpireCache struct {
// contains filtered or unexported fields
}
ExpireCache cache data with fixed capacity and duration from [now - duration,now], need to manually clear expired data
func NewExpireCache ¶ added in v1.3.0
func NewExpireCache(duration time.Duration, capacity int) *ExpireCache
NewExpireCache new cache instance
func (*ExpireCache) Cap ¶ added in v1.3.0
func (ec *ExpireCache) Cap() int
Cap return cache capacity
func (*ExpireCache) ExistsByKey ¶ added in v1.3.0
func (ec *ExpireCache) ExistsByKey(key string) bool
ExistsByKey if key in cache and not expire return ture, else return false
func (*ExpireCache) GetAll ¶ added in v1.3.0
func (ec *ExpireCache) GetAll() []interface{}
GetAll get not expire value in cache
func (*ExpireCache) GetByKey ¶ added in v1.3.0
func (ec *ExpireCache) GetByKey(key string) interface{}
GetByKey if key in cache and not expire return value, else return nil
func (*ExpireCache) IsFull ¶ added in v1.3.0
func (ec *ExpireCache) IsFull() bool
IsFull is the cache full
func (*ExpireCache) Put ¶ added in v1.3.0
func (ec *ExpireCache) Put(key string, v interface{}) bool
Put data to cache, if the cache is full, new data will not be put in
func (*ExpireCache) RemoveExpired ¶ added in v1.3.0
func (ec *ExpireCache) RemoveExpired()
RemoveExpired remove expired value
func (*ExpireCache) Size ¶ added in v1.3.0
func (ec *ExpireCache) Size() int
Size return cache data count
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) Exist ¶
Exist return whether the key given exist in cache.
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.
func (*FIFOCache) Remove ¶
Remove a key-value pair existed in cache. If the key existed return true, otherwise 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.
type Node ¶ added in v1.3.0
type Node struct {
// contains filtered or unexported fields
}
Node store cache info,
type PeerIdSet ¶
type PeerIdSet struct {
// contains filtered or unexported fields
}
PeerIdSet peerId set only store data of type peer.ID
func (*PeerIdSet) Exist ¶
Exist determine whether the specified data exists
func (*PeerIdSet) Range ¶
Range iterate over the data in the collection
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set collection structure definition only one copy of the same data set can exist
func (*Set) Exist ¶
Exist determine whether the specified data exists
func (*Set) Range ¶
Range iterate over the data in the collection
type StringSet ¶
type StringSet struct {
// contains filtered or unexported fields
}
StringSet unit64 set only store data of type string
func (*StringSet) Exist ¶
Exist determine whether the specified data exists
func (*StringSet) Range ¶
Range iterate over the data in the collection