jet / equinox

.NET event sourcing library with CosmosDB, DynamoDB, EventStoreDB, message-db, SqlStreamStore and integration test backends. Focused at stream level; see https://github.com/jet/propulsion for cross-stream projections/subscriptions/reactions
https://github.com/jet/dotnet-templates
Apache License 2.0
472 stars 68 forks source link

Feature: ReadThrough mode #381

Closed bartelink closed 1 year ago

bartelink commented 1 year ago

The current AllowStale option will use any cached state as held

Being able to constrain it to only use the state if it's within a certain age range will enable users to trigger periodic re-reads to freshen the state

To facilitate heavy usage as a read-through cache, reads under this mode should be concentrated internally via an AsyncCacheCell in order to ensure a timeout does not read to a flurry of concurrent update attempts

NOTE just letting the underlying entry in the MemoryCache expire is insufficient - we still need to have the entry be usable as base state for the read (e.g. in order to allow etag checked reads) and to be able to use it to control the single reader gating

nordfjord commented 1 year ago

This would be amazing. This has been a significant reason for me avoiding the AllowStale option. In most cases I'd be fine to use the state within e.g. 60 seconds, but if it's older than that it's usually no longer fresh enough for use in the query methods.