A few small, independent hardening items. Each is a good first issue and can be split out if someone wants to pick one up.
1. AOT / trimming compatibility
Mark the core package IsAotCompatible and enable the trim/AOT analyzers. The source-gen JSON context already helps; the generic HybridCache serializer path (NatsHybridCacheSerializer) is the part to validate.
2. Zero-copy TryGetAsync
NatsCache.TryGetAsync(string, IBufferWriter<byte>, …) currently fetches a byte[] and copies it into the destination (src/NatsDistributedCache/NatsCache.cs), partially defeating the point of IBufferDistributedCache. Investigate deserializing/writing directly into the supplied IBufferWriter<byte>.
3. Maintenance helper: clear-by-prefix / purge
For multi-tenant users of CacheKeyPrefix, provide a helper to purge entries by prefix. INatsKVStore.GetKeysAsync + PurgeAsync make this feasible.
Acceptance criteria
- Each item delivered (or split into its own issue) with a test where applicable.
A few small, independent hardening items. Each is a good first issue and can be split out if someone wants to pick one up.
1. AOT / trimming compatibility
Mark the core package
IsAotCompatibleand enable the trim/AOT analyzers. The source-gen JSON context already helps; the generic HybridCache serializer path (NatsHybridCacheSerializer) is the part to validate.2. Zero-copy
TryGetAsyncNatsCache.TryGetAsync(string, IBufferWriter<byte>, …)currently fetches abyte[]and copies it into the destination (src/NatsDistributedCache/NatsCache.cs), partially defeating the point ofIBufferDistributedCache. Investigate deserializing/writing directly into the suppliedIBufferWriter<byte>.3. Maintenance helper: clear-by-prefix / purge
For multi-tenant users of
CacheKeyPrefix, provide a helper to purge entries by prefix.INatsKVStore.GetKeysAsync+PurgeAsyncmake this feasible.Acceptance criteria