dotnet / dotnet/extensions

HybridCache serialization issues when in-memory

Open
#6,063 9 comments 7 reactions 0 assignees View on GitHub
api-suggestion area-caching-hybrid
Dominant language
C#
Stars
3.2k
Forks
894
Avg merge
1d 12h
Merged PRs (30d)
23

Description

### Description

I'm not sure if this is a bug or a misunderstanding, but when storing only locally, why is the data being serialized? I'd assume I could store any sort of object (interfaces, classes, etc) in a local, memory cache.

### Reproduction Steps

My factory function returns a Task of an interface (IBloomFilter in this case). I'm passing the `HybridCacheEntryFlags.DisableDistributedCache` flag into the cache method as follows:

return `hybridCache.GetOrCreate("BloomFilter", factory, HybridCacheEntryFlags.DisableDistributedCache)`

### Expected behavior

The object wouldn't go through serialization when caching locally in memory.

### Actual behavior

An exception is thrown: `System.NotSupportedException: Deserialization of interface or abstract types is not supported. Type 'BloomFilter.IBloomFilter'`

### Regression?

_No response_

### Known Workarounds

_No response_

### Configuration

.NET 9, HybridCache 9.2.0-preview1.25105.6

### Other information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.