Version: v1.0.12-0...-16f252f Latest Latest

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

Go to latest
Published: Sep 7, 2020 License: MIT Imports: 11 Imported by: 0




This section is empty.


This section is empty.


This section is empty.


type Bucket

type Bucket struct {
	Sum   float64
	Count int64

type Cache

type Cache struct {
	// contains filtered or unexported fields

func NewCache

func NewCache(expire time.Duration, opts ...CacheOption) (*Cache, error)

func (*Cache) Del

func (c *Cache) Del(key string)

func (*Cache) Get

func (c *Cache) Get(key string) (interface{}, bool)

func (*Cache) Set

func (c *Cache) Set(key string, value interface{})

func (*Cache) Take

func (c *Cache) Take(key string, fetch func() (interface{}, error)) (interface{}, error)

type CacheOption

type CacheOption func(cache *Cache)

func WithLimit

func WithLimit(limit int) CacheOption

func WithName

func WithName(name string) CacheOption

type Execute

type Execute func(key, value interface{})

type Queue

type Queue struct {
	// contains filtered or unexported fields

func NewQueue

func NewQueue(size int) *Queue

func (*Queue) Empty

func (q *Queue) Empty() bool

func (*Queue) Put

func (q *Queue) Put(element interface{})

func (*Queue) Take

func (q *Queue) Take() (interface{}, bool)

type Ring

type Ring struct {
	// contains filtered or unexported fields

func NewRing

func NewRing(n int) *Ring

func (*Ring) Add

func (r *Ring) Add(v interface{})

func (*Ring) Take

func (r *Ring) Take() []interface{}

type RollingWindow

type RollingWindow struct {
	// contains filtered or unexported fields

func NewRollingWindow

func NewRollingWindow(size int, interval time.Duration, opts ...RollingWindowOption) *RollingWindow

func (*RollingWindow) Add

func (rw *RollingWindow) Add(v float64)

func (*RollingWindow) Reduce

func (rw *RollingWindow) Reduce(fn func(b *Bucket))

type RollingWindowOption

type RollingWindowOption func(rollingWindow *RollingWindow)

func IgnoreCurrentBucket

func IgnoreCurrentBucket() RollingWindowOption

type SafeMap

type SafeMap struct {
	// contains filtered or unexported fields

SafeMap provides a map alternative to avoid memory leak. This implementation is not needed until issue below fixed.

func NewSafeMap

func NewSafeMap() *SafeMap

func (*SafeMap) Del

func (m *SafeMap) Del(key interface{})

func (*SafeMap) Get

func (m *SafeMap) Get(key interface{}) (interface{}, bool)

func (*SafeMap) Set

func (m *SafeMap) Set(key, value interface{})

func (*SafeMap) Size

func (m *SafeMap) Size() int

type Set

type Set struct {
	// contains filtered or unexported fields

func NewSet

func NewSet() *Set

func NewUnmanagedSet

func NewUnmanagedSet() *Set

func (*Set) Add

func (s *Set) Add(i ...interface{})

func (*Set) AddInt

func (s *Set) AddInt(ii

func (*Set) AddInt64

func (s *Set) AddInt64(ii ...int64)

func (*Set) AddStr

func (s *Set) AddStr(ss ...string)

func (*Set) AddUint

func (s *Set) AddUint(ii ...uint)

func (*Set) AddUint64

func (s *Set) AddUint64(ii ...uint64)

func (*Set) Contains

func (s *Set) Contains(i interface{}) bool

func (*Set) Count

func (s *Set) Count() int

func (*Set) Keys

func (s *Set) Keys() []interface{}

func (*Set) KeysInt

func (s *Set) KeysInt() []int

func (*Set) KeysInt64

func (s *Set) KeysInt64() []int64

func (*Set) KeysStr

func (s *Set) KeysStr() []string

func (*Set) KeysUint

func (s *Set) KeysUint() []uint

func (*Set) KeysUint64

func (s *Set) KeysUint64() []uint64

func (*Set) Remove

func (s *Set) Remove(i interface{})

type TimingWheel

type TimingWheel struct {
	// contains filtered or unexported fields

func NewTimingWheel

func NewTimingWheel(interval time.Duration, numSlots int, execute Execute) (*TimingWheel, error)

func (*TimingWheel) Drain

func (tw *TimingWheel) Drain(fn func(key, value interface{}))

func (*TimingWheel) MoveTimer

func (tw *TimingWheel) MoveTimer(key interface{}, delay time.Duration)

func (*TimingWheel) RemoveTimer

func (tw *TimingWheel) RemoveTimer(key interface{})

func (*TimingWheel) SetTimer

func (tw *TimingWheel) SetTimer(key, value interface{}, delay time.Duration)

func (*TimingWheel) Stop

func (tw *TimingWheel) Stop()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL