Problem
Consumers must pre-create the KV bucket with LimitMarkerTTL before using the cache (it's the most prominent step in the README). NatsCache calls INatsKVContext.GetStoreAsync (src/NatsDistributedCache/NatsCache.cs), which throws if the bucket doesn't exist.
Investigation
INatsKVContext exposes CreateOrUpdateStoreAsync / CreateStoreAsync / UpdateStoreAsync. NatsKVConfig exposes: LimitMarkerTTL, History, Storage, NumberOfReplicas, MaxBytes, MaxValueSize, Compression, MaxAge, Description, Placement, ….
Proposal
Add opt-in bucket auto-creation:
NatsCacheOptions.CreateBucketIfNotExists (default false — no surprise infra changes).
- A bucket-config hook (
Action<NatsKVConfig> or typed sub-options) to set storage/replicas/limits.
- When enabled, call
CreateOrUpdateStoreAsync with cache-appropriate defaults:
LimitMarkerTTL set (required for per-key TTL).
History = 1 (the existing PutWithTtl remarks require it for correct TTL behavior).
Acceptance criteria
- With the flag enabled, a missing bucket is created with
LimitMarkerTTL + History = 1.
- Disabled by default; existing behavior unchanged.
- The README's manual
CreateOrUpdateStoreAsync step becomes optional.
Problem
Consumers must pre-create the KV bucket with
LimitMarkerTTLbefore using the cache (it's the most prominent step in the README).NatsCachecallsINatsKVContext.GetStoreAsync(src/NatsDistributedCache/NatsCache.cs), which throws if the bucket doesn't exist.Investigation
INatsKVContextexposesCreateOrUpdateStoreAsync/CreateStoreAsync/UpdateStoreAsync.NatsKVConfigexposes:LimitMarkerTTL, History, Storage, NumberOfReplicas, MaxBytes, MaxValueSize, Compression, MaxAge, Description, Placement, ….Proposal
Add opt-in bucket auto-creation:
NatsCacheOptions.CreateBucketIfNotExists(defaultfalse— no surprise infra changes).Action<NatsKVConfig>or typed sub-options) to set storage/replicas/limits.CreateOrUpdateStoreAsyncwith cache-appropriate defaults:LimitMarkerTTLset (required for per-key TTL).History = 1(the existingPutWithTtlremarks require it for correct TTL behavior).Acceptance criteria
LimitMarkerTTL+History = 1.CreateOrUpdateStoreAsyncstep becomes optional.