frecency

package
v0.14.1 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DateWeight float64 = 1
View Source
var FrequencyWeight float64 = 1

change these to play with the weights values between 0 and 1 0 will exclude the metric all together from the ordering

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Entry                interface{}
	Frequency            int
	LastUsed             time.Time
	FrequencyScore       float64
	LastUsedScore        float64
	FrecencySortingScore float64
}

type FrecencyStore

type FrecencyStore struct {
	MaxFrequency int
	OldestDate   time.Time
	Entries      []*Entry
	// contains filtered or unexported fields
}

func Load

func Load(fecencyStoreKey string) (*FrecencyStore, error)

func (*FrecencyStore) Delete

func (store *FrecencyStore) Delete(toRemove interface{}) error

delete a single entry from the frecency store

func (*FrecencyStore) DeleteAll

func (store *FrecencyStore) DeleteAll(toRemove []interface{}) error

deletes all elements from the frecency store

func (*FrecencyStore) GetFrecentEntriess

func (store *FrecencyStore) GetFrecentEntriess(optionalLimit *int) []interface{}

Returns the cached entries stored in descending order by frecency, optionally limit the returned results

func (*FrecencyStore) Upsert

func (store *FrecencyStore) Upsert(newEntry interface{}) error

Save a new reason to the frecency cache. This operation will reevaluate the frecency scores after inserting the new reason if the reason already exists, the frequency will be increased as well as the last used date the newReason will always be saved at the top of the list

Jump to

Keyboard shortcuts

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