No Expiration Mode

Version 1.6.5 introduces a new configuration flag that allows you to disable automatic default expiration when absoluteExpiration is not provided.

This update gives you full control over TTL behavior while remaining 100% backward compatible.


🧠 Default Expiration Behavior

Previous Behavior (Still Default)

If you called:

await cache.SetAsync("key", value);

And did not provide absoluteExpiration, the cache service would automatically apply a default expiration (12 hours by default).

This behavior is preserved.


πŸ†• New Configuration Flag

You can now control this behavior using:

UseDefaultAbsoluteExpirationWhenNull

This flag determines whether the default TTL should be applied when no expiration is explicitly provided.

  • true (default): apply default TTL (old behavior)

  • false: do not apply TTL automatically (persistent keys in Redis / no auto-expiration behavior)


βš™οΈ Configuration (appsettings.json)


πŸ” Behavior Matrix

UseDefaultAbsoluteExpirationWhenNull
absoluteExpiration provided?
Resulting TTL

true (default)

βœ… Yes

Uses the provided TTL

true (default)

❌ No

Uses default TTL (e.g., 12 hours)

false

βœ… Yes

Uses the provided TTL

false

❌ No

No TTL is applied automatically

Notes:

  • In Redis, this means the key can become persistent (no expiration).

  • In InMemory, behavior depends on the underlying cache entry options (but the library will not force a default absolute TTL when this flag is false).


πŸ›‘ Backward Compatibility

If you do nothing, your system behaves exactly like previous versions.

βœ… Default is true, meaning:

  • βœ” No breaking changes

  • βœ” No migration required

  • βœ” Existing applications continue working as-is


🧩 Why This Was Added

Some use cases require:

  • Long-lived cache entries

  • Persistent Redis keys

  • Manual expiration control

  • Hybrid TTL strategies

  • External expiration management

Previously, the default TTL was always applied when absoluteExpiration was missing. Now you have full control.


πŸ§ͺ Usage Examples

➑ Stored with default expiration (e.g., 12 hours)

Persistent Key (No Expiration)

➑ Stored without expiration (Redis key becomes persistent)


πŸ”„ Applies To

The new flag affects both providers:

  • RENRedisCacheService

  • RENInMemoryCacheService

Both providers respect the same configuration behavior.


🧱 New DI Registration Overload (Configuration-Based)

Version 1.6.5 also introduces a configuration-based registration overload.

Instead of manually configuring options, you can now do:

Or with custom interface + implementation:

βœ… This automatically binds:

  • "CacheConfiguration"

into:

  • RENCacheKitOptions

So no manual Configure<RENCacheKitOptions>() is required.


🧩 Custom Cache Services (Important)

If you provide your own cache service implementation (e.g. deriving from the base services), make sure your constructor accepts and forwards the options so the configuration is actually applied.

βœ… Redis (custom implementation)

βœ… InMemory (custom implementation)

If you don’t take/forward IOptions<RENCacheKitOptions>, the base services may fall back to defaults, and your UseDefaultAbsoluteExpirationWhenNull setting won’t have any effect.


Keep UseDefaultAbsoluteExpirationWhenNull = true unless:

  • You intentionally want persistent keys

  • You manage TTL manually

  • You need strict expiration policy control

  • You operate with hybrid expiration models


πŸš€ Summary

Version 1.6.5 introduces:

  • Optional persistent key support (when expiration is omitted)

  • Full TTL control via UseDefaultAbsoluteExpirationWhenNull

  • Zero breaking changes (default behavior preserved)

  • Configuration-based DI overload

  • Unified behavior across Redis & InMemory providers

Last updated