Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cached Repository #126

Open
bounoable opened this issue May 31, 2023 · 1 comment
Open

Cached Repository #126

bounoable opened this issue May 31, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@bounoable
Copy link
Contributor

Provide an Aggregate Repository with cache features.

  • Cache fetches of aggregates
  • Cache based on queries (Query Cache #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()
}
@bounoable bounoable added the enhancement New feature or request label May 31, 2023
@bounoable
Copy link
Contributor Author

Fetch() cache implemented in 4b51c72

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant