types

package
v0.0.0-...-dae542e Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2022 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
}

func (*ConnSet) Exist

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

func (*ConnSet) Put

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

func (*ConnSet) Range

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

func (*ConnSet) Remove

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

func (*ConnSet) Size

func (cs *ConnSet) Size() int

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 PeerIdSet

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

func (*PeerIdSet) Exist

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

func (*PeerIdSet) Put

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

func (*PeerIdSet) Range

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

func (*PeerIdSet) Remove

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

func (*PeerIdSet) Size

func (ps *PeerIdSet) Size() int

type Set

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

func (*Set) Exist

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

func (*Set) Put

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

func (*Set) Range

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

func (*Set) Remove

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

func (*Set) Size

func (s *Set) Size() int

type StringSet

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

func (*StringSet) Exist

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

func (*StringSet) Put

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

func (*StringSet) Range

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

func (*StringSet) Remove

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

func (*StringSet) Size

func (ss *StringSet) Size() int

type Uint64Set

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

func (*Uint64Set) Exist

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

func (*Uint64Set) Put

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

func (*Uint64Set) Range

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

func (*Uint64Set) Remove

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

func (*Uint64Set) Size

func (us *Uint64Set) Size() int

Jump to

Keyboard shortcuts

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