Documentation ¶
Index ¶
- type EntityRepository
- type ExtendedSource
- type Hit
- type HitRepository
- type Manager
- func (m *Manager[Entity, ID]) CacheQueryMany(ctx context.Context, name string, query func() iterators.Iterator[Entity]) iterators.Iterator[Entity]
- func (m *Manager[Entity, ID]) CacheQueryOne(ctx context.Context, queryID string, ...) (_ent Entity, _found bool, _err error)
- func (m *Manager[Entity, ID]) Close() error
- func (m *Manager[Entity, ID]) Create(ctx context.Context, ptr *Entity) error
- func (m *Manager[Entity, ID]) DeleteAll(ctx context.Context) error
- func (m *Manager[Entity, ID]) DeleteByID(ctx context.Context, id ID) error
- func (m *Manager[Entity, ID]) FindAll(ctx context.Context) iterators.Iterator[Entity]
- func (m *Manager[Entity, ID]) FindByID(ctx context.Context, id ID) (Entity, bool, error)
- func (m *Manager[Entity, ID]) Init(ctx context.Context) error
- func (m *Manager[Entity, ID]) SubscribeToCreatorEvents(ctx context.Context, creatorSubscriber pubsub.CreatorSubscriber[Entity]) (pubsub.Subscription, error)
- func (m *Manager[Entity, ID]) SubscribeToDeleterEvents(ctx context.Context, s pubsub.DeleterSubscriber[ID]) (pubsub.Subscription, error)
- func (m *Manager[Entity, ID]) SubscribeToUpdaterEvents(ctx context.Context, s pubsub.UpdaterSubscriber[Entity]) (pubsub.Subscription, error)
- func (m *Manager[Entity, ID]) Update(ctx context.Context, ptr *Entity) error
- type Repository
- type Source
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EntityRepository ¶ added in v0.82.0
type ExtendedSource ¶
type ExtendedSource[Entity, ID any] interface { crud.Updater[Entity] pubsub.UpdaterPublisher[Entity] }
type HitRepository ¶ added in v0.82.0
type HitRepository[EntID any] interface { crud.Creator[Hit[EntID]] crud.Updater[Hit[EntID]] crud.Finder[Hit[EntID], string] crud.Deleter[string] }
HitRepository is the query hit result repository.
type Manager ¶
type Manager[Entity, ID any] struct { // Source is the location of the original data Source Source[Entity, ID] // Repository is the resource that keeps the cached data. Repository Repository[Entity, ID] // contains filtered or unexported fields }
func NewManager ¶
func NewManager[Entity, ID any](repository Repository[Entity, ID], source Source[Entity, ID]) (*Manager[Entity, ID], error)
func (*Manager[Entity, ID]) CacheQueryMany ¶
func (*Manager[Entity, ID]) CacheQueryOne ¶
func (*Manager[Entity, ID]) DeleteByID ¶
func (*Manager[Entity, ID]) SubscribeToCreatorEvents ¶
func (m *Manager[Entity, ID]) SubscribeToCreatorEvents(ctx context.Context, creatorSubscriber pubsub.CreatorSubscriber[Entity]) (pubsub.Subscription, error)
func (*Manager[Entity, ID]) SubscribeToDeleterEvents ¶
func (m *Manager[Entity, ID]) SubscribeToDeleterEvents(ctx context.Context, s pubsub.DeleterSubscriber[ID]) (pubsub.Subscription, error)
func (*Manager[Entity, ID]) SubscribeToUpdaterEvents ¶
func (m *Manager[Entity, ID]) SubscribeToUpdaterEvents(ctx context.Context, s pubsub.UpdaterSubscriber[Entity]) (pubsub.Subscription, error)
type Repository ¶ added in v0.82.0
type Repository[Entity, ID any] interface { CacheEntity(ctx context.Context) EntityRepository[Entity, ID] CacheHit(ctx context.Context) HitRepository[ID] comproto.OnePhaseCommitProtocol }
type Source ¶
type Source[Entity, ID any] interface { crud.Creator[Entity] crud.Finder[Entity, ID] crud.Deleter[ID] pubsub.CreatorPublisher[Entity] pubsub.DeleterPublisher[ID] }
Source is the minimum expected interface that is expected from a Source resources that needs caching. On top of this, cache.Manager also supports Updater, CreatorPublisher, UpdaterPublisher and DeleterPublisher.
Click to show internal directories.
Click to hide internal directories.