herocache

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2022 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache implements an array-based generic memory pool backed by a fixed total array.

func NewCache

func NewCache(sizeLimit uint32, oversizeFactor uint32, ejectionMode heropool.EjectionMode, logger zerolog.Logger) *Cache

func (*Cache) Add

func (c *Cache) Add(entityID flow.Identifier, entity flow.Entity) bool

Add adds the given item to the BackData.

func (*Cache) Adjust

func (c *Cache) Adjust(entityID flow.Identifier, f func(flow.Entity) flow.Entity) (flow.Entity, bool)

Adjust will adjust the value item using the given function if the given identifier can be found. Returns a bool which indicates whether the value was updated as well as the updated value.

func (Cache) All

func (c Cache) All() map[flow.Identifier]flow.Entity

All returns all entities from the BackData.

func (*Cache) ByID

func (c *Cache) ByID(entityID flow.Identifier) (flow.Entity, bool)

ByID returns the given entity from the BackData.

func (*Cache) Clear

func (c *Cache) Clear()

Clear removes all entities from the BackData.

func (*Cache) Has

func (c *Cache) Has(entityID flow.Identifier) bool

Has checks if we already contain the entity with the given identifier.

func (*Cache) Hash

func (c *Cache) Hash() flow.Identifier

Hash will use a merkle root hash to hash all items.

func (*Cache) Rem

func (c *Cache) Rem(entityID flow.Identifier) (flow.Entity, bool)

Rem will remove the item with the given identity.

func (Cache) Size

func (c Cache) Size() uint

Size will return the total size of BackData, i.e., total number of valid (entityId, entity) pairs.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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