cache

package
v0.15.5 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Repo

type Repo struct {
	eh.ReadWriteRepo
	// contains filtered or unexported fields
}

Repo is a middleware that adds caching to a read repository. It will update the cache when it receives events affecting the cached items. The primary purpose is to use it with smaller collections accessed often. Note that there is no limit to the cache size.

func IntoRepo added in v0.14.0

func IntoRepo(ctx context.Context, repo eh.ReadRepo) *Repo

IntoRepo tries to convert a eh.ReadRepo into a Repo by recursively looking at inner repos. Returns nil if none was found.

func NewRepo

func NewRepo(repo eh.ReadWriteRepo) *Repo

NewRepo creates a new Repo.

func (*Repo) Find

func (r *Repo) Find(ctx context.Context, id uuid.UUID) (eh.Entity, error)

Find implements the Find method of the eventhorizon.ReadModel interface.

func (*Repo) FindAll

func (r *Repo) FindAll(ctx context.Context) ([]eh.Entity, error)

FindAll implements the FindAll method of the eventhorizon.ReadRepo interface.

func (*Repo) HandleEvent added in v0.7.0

func (r *Repo) HandleEvent(ctx context.Context, event eh.Event) error

HandleEvent implements the HandleEvent method of the eventhorizon.EventHandler interface. It will bust the cache for any updates to the relevant aggregate. The repo should be added with a eh.MatchAny or eh.MatchAggregate for best effect (depending on if the underlying repo is used for all or individual aggregate types).

func (*Repo) HandlerType added in v0.7.0

func (r *Repo) HandlerType() eh.EventHandlerType

HandlerType implements the HandlerType method of the eventhorizon.EventHandler interface.

func (*Repo) InnerRepo added in v0.14.0

func (r *Repo) InnerRepo(ctx context.Context) eh.ReadRepo

InnerRepo implements the InnerRepo method of the eventhorizon.ReadRepo interface.

func (*Repo) Remove

func (r *Repo) Remove(ctx context.Context, id uuid.UUID) error

Remove implements the Remove method of the eventhorizon.WriteRepo interface.

func (*Repo) Save

func (r *Repo) Save(ctx context.Context, entity eh.Entity) error

Save implements the Save method of the eventhorizon.WriteRepo interface.

Jump to

Keyboard shortcuts

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