types

package
v1.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 27, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

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

func (cs *ConnSet) Exist(conn network.Conn) bool

Exist determine whether the specified data exists

func (*ConnSet) Put

func (cs *ConnSet) Put(conn network.Conn) bool

Put data

func (*ConnSet) Range

func (cs *ConnSet) Range(f func(conn network.Conn) bool)

Range iterate over the data in the collection

func (*ConnSet) Remove

func (cs *ConnSet) Remove(conn network.Conn) bool

Remove data

func (*ConnSet) Size

func (cs *ConnSet) Size() int

Size the current number of elements 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

func NewFIFOCache(cap int, threadSafe bool) *FIFOCache

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

func (c *FIFOCache) Exist(k interface{}) bool

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) Put

func (c *FIFOCache) Put(k, v interface{})

Put a key-value pair to cache.

func (*FIFOCache) PutIfNotExist

func (c *FIFOCache) PutIfNotExist(k, v interface{}) bool

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

func (c *FIFOCache) Remove(k interface{}) bool

Remove a key-value pair existed in cache. If the key existed return true, otherwise return false.

func (*FIFOCache) Reset

func (c *FIFOCache) Reset()

Reset clear all the entries in cache.

func (*FIFOCache) Size

func (c *FIFOCache) Size() int

Size is the current entries count in cache.

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]

func NewInterval

func NewInterval(start, end uint64) *Interval

NewInterval create a new Interval

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) Add

func (is *IntervalSet) Add(iv *Interval)

Add an Interval to IntervalSet.

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

func (ps *PeerIdSet) Exist(pid peer.ID) bool

Exist determine whether the specified data exists

func (*PeerIdSet) Put

func (ps *PeerIdSet) Put(pid peer.ID) bool

Put data

func (*PeerIdSet) Range

func (ps *PeerIdSet) Range(f func(pid peer.ID) bool)

Range iterate over the data in the collection

func (*PeerIdSet) Remove

func (ps *PeerIdSet) Remove(pid peer.ID) bool

Remove data

func (*PeerIdSet) Size

func (ps *PeerIdSet) Size() int

Size the current number of elements 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

func (s *Set) Exist(v interface{}) bool

Exist determine whether the specified data exists

func (*Set) Put

func (s *Set) Put(v interface{}) bool

Put data

func (*Set) Range

func (s *Set) Range(f func(v interface{}) bool)

Range iterate over the data in the collection

func (*Set) Remove

func (s *Set) Remove(v interface{}) bool

Remove data

func (*Set) Size

func (s *Set) Size() int

Size the current number of elements 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

func (ss *StringSet) Exist(str string) bool

Exist determine whether the specified data exists

func (*StringSet) Put

func (ss *StringSet) Put(str string) bool

Put data

func (*StringSet) Range

func (ss *StringSet) Range(f func(str string) bool)

Range iterate over the data in the collection

func (*StringSet) Remove

func (ss *StringSet) Remove(str string) bool

Remove data

func (*StringSet) Size

func (ss *StringSet) Size() int

Size the current number of elements in the collection

type Uint64Set

type Uint64Set struct {
	// contains filtered or unexported fields
}

Uint64Set unit64 set only store data of type uint64

func (*Uint64Set) Exist

func (us *Uint64Set) Exist(v uint64) bool

Exist determine whether the specified data exists

func (*Uint64Set) Put

func (us *Uint64Set) Put(v uint64) bool

Put data

func (*Uint64Set) Range

func (us *Uint64Set) Range(f func(v uint64) bool)

Range iterate over the data in the collection

func (*Uint64Set) Remove

func (us *Uint64Set) Remove(v uint64) bool

Remove data

func (*Uint64Set) Size

func (us *Uint64Set) Size() int

Size the current number of elements in the collection

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL