Cached Repository
Opened this issue · 1 comments
bounoable commented
Provide an Aggregate Repository with cache features.
- Cache fetches of aggregates
- Cache based on queries (#59)
- Clear cache
package example
func example(repo aggregate.Repository) { // or aggregate.TypedRepository[...]
cached := repository.NewCache(repo)
// Only runs once
q := query.New(...)
cached.Query(context.TODO(), q)
cached.Query(context.TODO(), q)
// Only runs once
id := uuid.New()
cached.Fetch(context.TODO(), id)
cached.Fetch(context.TODO(), id)
// Clear cache
cached.Reset()
}