Open bounoable opened 2 years ago
Implement a flexible cache for event queries.
package example import ( "github.com/modernice/goes/event" "github.com/modernice/goes/event/query" ) func example(store event.Store, q event.Query) { cache := query.NewCache(store) result, err := cache.Result(context.TODO(), q) // handle err if result.Cached { log.Println("cache returned cached result") } else { log.Println("cache executed query") } events, err := streams.Drain(context.TODO(), result.Events, result.Errs) // handle err // alternatively str, errs, err := cache.Run(context.TODO(), q) // handle err events, err := streams.Drain(context.TODO(), str, errs) }
This would allow for an aggregate cache:
package example func example(repo aggregate.Repository) { cached := repository.Cached(repo) var foo aggregate.Aggregate err := cached.Fetch(context.TODO(), foo) }
Implement a flexible cache for event queries.
Features
Examples
Basic usage