SqliteCache icon indicating copy to clipboard operation
SqliteCache copied to clipboard

Any plan to support the new `IBufferDistributedCache` interface?

Open jodydonetti opened this issue 11 months ago • 3 comments
trafficstars

Hi all! Some users of my caching library FusionCache are using this IDistributedCache implementation as an L2, mainly in mobile apps and games. I was wondering if you are planning to add support for the new IBufferDistributedCache interface to get even better perf.

jodydonetti avatar Dec 21 '24 00:12 jodydonetti

The short version of this change is "exactly the same thing, but without allocating a byte[] every call"; here's the SE.Redis implementation for reference: https://github.com/dotnet/aspnetcore/blob/main/src/Caching/StackExchangeRedis/src/RedisCache.cs#L694

Or the key bits from the SQL Server version (probably closer): https://github.com/dotnet/aspnetcore/blob/main/src/Caching/SqlServer/src/DatabaseOperations.cs#L313

mgravell avatar Dec 21 '24 07:12 mgravell

Sure, this sounds like a decent feature to add. I'm not sure how often we'll be able to avoid allocating without looking into this further to see what the common usage patterns are like, but it's definitely worth considering!

mqudsi avatar Dec 22 '24 00:12 mqudsi

Note: if you can't avoid allocating the right sized array in at least one direction (read, write), then there would be no advantage to implementing this new interface. The relevant mechanisms already use type-testing to use the most appropriate API available.

mgravell avatar Dec 22 '24 07:12 mgravell