cache

package
v0.0.0-...-1420a53 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewULID

func NewULID() string

NewULID returns a new ULID.

Types

type Base

type Base struct {
	log.BasicLogable
	// contains filtered or unexported fields
}

Base is the base structure for implementing a cache.

func (*Base) AddFlushCallback

func (c *Base) AddFlushCallback(f CallbackFunc)

AddFlushCallback appends the function f to the list of functions that will be called on successful flush of the cache. Note that the callback will not be called if the flush fails. Note also that the callback function will not be called concurrently (within a cache -- if you share the same callback function across multiple caches then, of course, it might be called concurrently).

func (*Base) Len

func (c *Base) Len() int

Len returns the number of objects currently in the cache.

type CallbackFunc

type CallbackFunc func(lg log.Interface) error

CallbackFunc is a function that will be called after the cache has been successfully flushed to the table. If the callback function returns an error then the cache will be placed in an error state.

type Completed

type Completed struct {
	*Base
	// contains filtered or unexported fields
}

Completed is a cache for storing completed polytopes.

func NewCompleted

func NewCompleted(maxSize int, t *keyvalue.Table) *Completed

NewCompleted returns a new cache for completed smooth polytopes. The maximum cache size before flushing is maxSize, and the data will be written to the given table.

func (*Completed) Add

func (c *Completed) Add(x []*integervector.Element) error

Add places x onto the cache.

func (*Completed) Close

func (c *Completed) Close() (err error)

Close closes the cache. Any cached data will be flushed.

type Partial

type Partial struct {
	*Base
	C <-chan *partial.State // Partial states can be pulled from the cache via this channel. This channel will be closed when the cache is closed. Note that a cache is unordered: the order in which partial states are recovered from the cache via this channel has no relation to the order in which they were added to the cache.
	// contains filtered or unexported fields
}

Partial is a cache for storing partial state data.

func NewPartial

func NewPartial(maxSize int, t *keyvalue.Table) *Partial

NewPartial returns a new cache for partial state data. The maximum cache size before flushing is maxSize, and the data will be written to the given table.

func (*Partial) Add

func (c *Partial) Add(x *partial.State) error

Add places x onto the cache.

func (*Partial) Close

func (c *Partial) Close() (err error)

Close closes the cache. Any cached data will be flushed, and the ULIDs used to populate the cache will be deleted from the partial state table. If flushing fails, or if the cache has been placed in an error state via MarkAsFailed, then an attempt will be made to mark the ULIDs as unprocessed.

func (*Partial) MarkAsFailed

func (c *Partial) MarkAsFailed()

MarkAsFailed places the cache in an error state. Upon closing the cache via Close, any cached data will be dropped, and the ULIDs used to populate the cache will be marked as unprocessed.

Jump to

Keyboard shortcuts

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