rolling

package
v0.0.0-...-be6f5f5 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RollDaily roll filter every day
	RollDaily = clock.DayUnit
	// RollWeekly roll filter every week
	RollWeekly = clock.WeekUnit
	// RollMonthly roll filter every month
	RollMonthly = clock.MonthUnit
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Filter

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

Filter provides functionality of working with multiple sequential filters through time

func NewFilter

func NewFilter(namer Namer, unit clock.Unit, period clock.UnitNum) (*Filter, error)

NewFilter creates a new Filter unit - unit of time, e.g. Week, Day or Month. All keys being set during period with a same unit will be stored in a single filter. period - period in specified time units to consider in check operations namer - provides algorithm to name filters according to specified unit of time

func (*Filter) BulkSet

func (rf *Filter) BulkSet(ctx context.Context, cli *bloomd.Client, reader bloomd.KeyReader) (bloomd.ResultReader, error)

BulkSet sets keys to filter that corresponds to a lates unit note that it does not check if filter exists

func (*Filter) Check

func (rf *Filter) Check(ctx context.Context, cli *bloomd.Client, k bloomd.Key) (bool, error)

Check sequentially checks filters through period note that it does not check if filters exist

func (*Filter) Clear

func (rf *Filter) Clear(ctx context.Context, cli *bloomd.Client) error

Clear clears all filters through period

func (*Filter) Close

func (rf *Filter) Close(ctx context.Context, cli *bloomd.Client) error

Close closes all filters through period

func (*Filter) CreateFilters

func (rf *Filter) CreateFilters(ctx context.Context, cli *bloomd.Client, advance clock.UnitNum, capacity int, prob float64, inMemory bool) error

CreateFilters creates all filters through a specified period if advance is greater than 0 that it will preallocate filters

func (*Filter) Drop

func (rf *Filter) Drop(ctx context.Context, cli *bloomd.Client) error

Drop drops all filters through period

func (*Filter) DropOlderFilters

func (rf *Filter) DropOlderFilters(ctx context.Context, cli *bloomd.Client, tail clock.UnitNum) error

DropOlderFilters drops all filters that correspond to units older that period if tail is greater that 0 that it will preserve some old filters

func (*Filter) Flush

func (rf *Filter) Flush(ctx context.Context, cli *bloomd.Client) error

Flush flushes all filters through period

func (*Filter) MultiCheck

func (rf *Filter) MultiCheck(ctx context.Context, cli *bloomd.Client, rr input.KeyReaderReseter) (resultReader bloomd.ResultReader, err error)

MultiCheck sequentially checks filters through period note that it does not check if filters exist

func (*Filter) Set

func (rf *Filter) Set(ctx context.Context, cli *bloomd.Client, k bloomd.Key) (bool, error)

Set sets key to filter that corresponds to a lates unit note that it does not check if filter exists

type Namer

type Namer interface {
	NameFor(unit clock.UnitNum) string
	ParseUnit(name string) (clock.UnitNum, error)
}

Namer maps filter names to units

Jump to

Keyboard shortcuts

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