6 |
7 | # 🛡️ Cache Stampede protection
8 |
9 | This content has been moved to the [CacheStampede](CacheStampede.md) page.
--------------------------------------------------------------------------------
/docs/Update_v1_0_0.md:
--------------------------------------------------------------------------------
1 |
6 |
7 | # 🆙 Update to v1.0.0
8 |
9 | If you are updating to `v1.0` from a previous version, in general everything should be fine.
10 |
11 | But, in some niche and specific cases, you may have to look out for some minor details or deprecations.
12 |
13 | The 2 minor (but still technically breaking) changes are:
14 | - slightly changed the nullability annotations with generics for the return values in the `GetOrSet` and `GetOrSetAsync`
15 | - the `FusionCacheEntryOptions.Size` option went from being `long` to `long?`
16 |
17 | Historically there have been only 2 versions that needed some attention, so please read the update notes if you are updating from a previous version:
18 |
19 | - to update from a version before `v0.20.0` ([update notes](Update_v0_20_0.md))
20 | - to update from a version before `v0.24.0` ([update notes](Update_v0_24_0.md))
21 |
22 | Apart from these everything should be quite smooth.
23 |
24 | In case something has been deprecated with time, there will be some warnings at compile time thanks to the usage of the `[Obsolete]` attribute along with useful instructions to follow, what to change, etc.
25 |
26 | That's all, happy updating!
--------------------------------------------------------------------------------
/docs/google-award-128x128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/google-award-128x128.png
--------------------------------------------------------------------------------
/docs/google-award-256x256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/google-award-256x256.png
--------------------------------------------------------------------------------
/docs/images/background-distributed-operations.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/images/background-distributed-operations.png
--------------------------------------------------------------------------------
/docs/images/cache-stampede-after.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/images/cache-stampede-after.png
--------------------------------------------------------------------------------
/docs/images/cache-stampede-before.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/images/cache-stampede-before.png
--------------------------------------------------------------------------------
/docs/images/cold-start.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/images/cold-start.png
--------------------------------------------------------------------------------
/docs/images/crinkle-crankle-wall.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/images/crinkle-crankle-wall.jpg
--------------------------------------------------------------------------------
/docs/images/diagram-extended.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/images/diagram-extended.png
--------------------------------------------------------------------------------
/docs/images/diagram.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/images/diagram.png
--------------------------------------------------------------------------------
/docs/images/diagrams.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/images/diagrams.png
--------------------------------------------------------------------------------
/docs/images/factory-optimization.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/images/factory-optimization.png
--------------------------------------------------------------------------------
/docs/images/fail-safe-after.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/images/fail-safe-after.png
--------------------------------------------------------------------------------
/docs/images/fail-safe-before.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/images/fail-safe-before.png
--------------------------------------------------------------------------------
/docs/images/fusioncache-simulator-autorecovery.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/images/fusioncache-simulator-autorecovery.png
--------------------------------------------------------------------------------
/docs/images/horizontal-scalability.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/images/horizontal-scalability.png
--------------------------------------------------------------------------------
/docs/images/opentelemetry-example.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/images/opentelemetry-example.png
--------------------------------------------------------------------------------
/docs/images/redis-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/images/redis-logo.png
--------------------------------------------------------------------------------
/docs/images/stepbystep-00-database.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/images/stepbystep-00-database.png
--------------------------------------------------------------------------------
/docs/images/stepbystep-00-nocache.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/images/stepbystep-00-nocache.png
--------------------------------------------------------------------------------
/docs/images/stepbystep-01-memorycache.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/images/stepbystep-01-memorycache.png
--------------------------------------------------------------------------------
/docs/images/stepbystep-02-fusioncache.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/images/stepbystep-02-fusioncache.png
--------------------------------------------------------------------------------
/docs/images/stepbystep-03-failsafe.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/images/stepbystep-03-failsafe.png
--------------------------------------------------------------------------------
/docs/images/stepbystep-04-factorytimeouts.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/images/stepbystep-04-factorytimeouts.png
--------------------------------------------------------------------------------
/docs/images/stepbystep-05-distributedcache.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/images/stepbystep-05-distributedcache.png
--------------------------------------------------------------------------------
/docs/images/stepbystep-06-distributedoptions.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/images/stepbystep-06-distributedoptions.png
--------------------------------------------------------------------------------
/docs/images/stepbystep-07-backplane.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/images/stepbystep-07-backplane.png
--------------------------------------------------------------------------------
/docs/images/stepbystep-intro.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/images/stepbystep-intro.png
--------------------------------------------------------------------------------
/docs/images/talk-on-dotnet.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/images/talk-on-dotnet.jpg
--------------------------------------------------------------------------------
/docs/images/talks/continuous-delivery.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/images/talks/continuous-delivery.jpg
--------------------------------------------------------------------------------
/docs/images/talks/data-exposed.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/images/talks/data-exposed.jpg
--------------------------------------------------------------------------------
/docs/images/talks/dotnet-podcast.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/images/talks/dotnet-podcast.jpg
--------------------------------------------------------------------------------
/docs/images/talks/dotnetconf-italia.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/images/talks/dotnetconf-italia.jpg
--------------------------------------------------------------------------------
/docs/images/talks/live-coding-alla-scoperta-di-fusioncache.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/images/talks/live-coding-alla-scoperta-di-fusioncache.jpg
--------------------------------------------------------------------------------
/docs/images/talks/on-dotnet-2025.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/images/talks/on-dotnet-2025.jpg
--------------------------------------------------------------------------------
/docs/images/talks/on-dotnet-small.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/images/talks/on-dotnet-small.jpg
--------------------------------------------------------------------------------
/docs/images/talks/on-dotnet.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/images/talks/on-dotnet.jpg
--------------------------------------------------------------------------------
/docs/images/talks/open-at-microsoft.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/images/talks/open-at-microsoft.jpg
--------------------------------------------------------------------------------
/docs/images/talks/small-talks.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/images/talks/small-talks.jpg
--------------------------------------------------------------------------------
/docs/images/talks/spike-time.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/images/talks/spike-time.jpg
--------------------------------------------------------------------------------
/docs/images/timeouts-timeline-background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/images/timeouts-timeline-background.png
--------------------------------------------------------------------------------
/docs/images/timeouts-timeline-blocking.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/images/timeouts-timeline-blocking.png
--------------------------------------------------------------------------------
/docs/logo-128x128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/logo-128x128.png
--------------------------------------------------------------------------------
/docs/logo-256x256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/logo-256x256.png
--------------------------------------------------------------------------------
/docs/logo-400x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/logo-400x400.png
--------------------------------------------------------------------------------
/docs/logo-plugin-128x128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/logo-plugin-128x128.png
--------------------------------------------------------------------------------
/docs/logo-plugin-256x256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/logo-plugin-256x256.png
--------------------------------------------------------------------------------
/docs/logo-plugin-400x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/logo-plugin-400x400.png
--------------------------------------------------------------------------------
/docs/mvp-award-128x128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/docs/mvp-award-128x128.png
--------------------------------------------------------------------------------
/global.json:
--------------------------------------------------------------------------------
1 | {
2 | "sdk": {
3 | "version": "9.0.102",
4 | "allowPrerelease": true,
5 | "rollForward": "latestFeature"
6 | }
7 | }
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.AspNetCore.OutputCaching/FusionOutputCacheOptions.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 |
3 | namespace ZiggyCreatures.Caching.Fusion.AspNetCore.OutputCaching;
4 |
5 | ///
6 | /// Options for configuring OutputCache with FusionCache.
7 | ///
8 | [DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")]
9 | public class FusionOutputCacheOptions
10 | {
11 | ///
12 | /// The name of the cache to use for output caching: if left to , the default cache (with a name equal to ) will be used.
13 | ///
14 | public string? CacheName { get; set; }
15 |
16 | private string GetDebuggerDisplay()
17 | {
18 | return $"OutputCache Name={CacheName}";
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.AspNetCore.OutputCaching/FusionOutputCacheStore.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.OutputCaching;
2 |
3 | namespace ZiggyCreatures.Caching.Fusion.AspNetCore.OutputCaching;
4 |
5 | internal sealed class FusionOutputCacheStore : IOutputCacheStore
6 | {
7 | private readonly IFusionCache _cache;
8 |
9 | public FusionOutputCacheStore(IFusionCache cache)
10 | {
11 | ArgumentNullException.ThrowIfNull(cache, nameof(cache));
12 |
13 | _cache = cache;
14 | }
15 |
16 | ///
17 | public async ValueTask EvictByTagAsync(string tag, CancellationToken cancellationToken)
18 | {
19 | await _cache.RemoveByTagAsync(tag, token: cancellationToken);
20 | }
21 |
22 | ///
23 | public async ValueTask GetAsync(string key, CancellationToken cancellationToken)
24 | {
25 | return await _cache.GetOrDefaultAsync(key, null, token: cancellationToken);
26 | }
27 |
28 | ///
29 | public async ValueTask SetAsync(string key, byte[] value, string[]? tags, TimeSpan validFor, CancellationToken cancellationToken)
30 | {
31 | await _cache.SetAsync(key, value, options => options.SetDuration(validFor).SetSize(value.Length), tags, token: cancellationToken);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.AspNetCore.OutputCaching/ZiggyCreatures.FusionCache.AspNetCore.OutputCaching.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0;net8.0
5 | 2.2.0
6 | ZiggyCreatures.FusionCache.AspNetCore.OutputCaching
7 | ASP.NET Output Cache based on FusionCache
8 | aspnet;outputcache;caching;cache;hybrid;hybrid-cache;hybridcache;multi-level;multilevel;fusion;fusioncache;fusion-cache;performance;async;ziggy
9 | ZiggyCreatures.Caching.Fusion.AspNetCore.OutputCaching
10 | true
11 |
12 | - Update: package dependencies
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.AspNetCore.OutputCaching/artwork/logo-128x128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/src/ZiggyCreatures.FusionCache.AspNetCore.OutputCaching/artwork/logo-128x128.png
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.AspNetCore.OutputCaching/docs/README.md:
--------------------------------------------------------------------------------
1 | # FusionCache
2 |
3 | 
4 |
5 | ### FusionCache is an easy to use, fast and robust hybrid cache with advanced resiliency features.
6 |
7 | It was born after years of dealing with all sorts of different types of caches: memory caching, distributed caching, http caching, CDNs, browser cache, offline cache, you name it. So I've tried to put together these experiences and came up with FusionCache.
8 |
9 | Find out [more](https://github.com/ZiggyCreatures/FusionCache).
10 |
11 | ## 📦 This package
12 |
13 | This package contains the ASP.NET [Output Cache](https://learn.microsoft.com/en-us/aspnet/core/performance/caching/output) implementation for FusionCache.
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.Backplane.Memory/GlobalSuppressions.cs:
--------------------------------------------------------------------------------
1 | // This file is used by Code Analysis to maintain SuppressMessage
2 | // attributes that are applied to this project.
3 | // Project-level suppressions either have no target or are given
4 | // a specific target and scoped to a namespace, type, member, etc.
5 |
6 | using System.Diagnostics.CodeAnalysis;
7 |
8 | [assembly: SuppressMessage("Simplification", "RCS1049:Simplify boolean comparison.")]
9 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.Backplane.Memory/MemoryBackplaneOptions.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Extensions.Options;
2 |
3 | namespace ZiggyCreatures.Caching.Fusion.Backplane.Memory;
4 |
5 | ///
6 | /// Represents the options available for the memory backplane.
7 | ///
8 | public class MemoryBackplaneOptions
9 | : IOptions
10 | {
11 | ///
12 | /// The logical id used to simulate a connection to a server.
13 | ///
14 | /// It is used to group together multiple instances of a MemoryBackplane and separate them from others, without interfering with other backplanes running concurrently at the same time (mostly useful for testing).
15 | ///
16 | /// Basically it's like a connection string.
17 | ///
18 | public string? ConnectionId { get; set; }
19 |
20 | MemoryBackplaneOptions IOptions.Value
21 | {
22 | get { return this; }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.Backplane.Memory/ZiggyCreatures.FusionCache.Backplane.Memory.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | 2.2.0
6 | ZiggyCreatures.FusionCache.Backplane.Memory
7 | FusionCache in memory backplane, used for testing
8 | backplane;memory;caching;cache;hybrid;hybrid-cache;hybridcache;multi-level;multilevel;fusion;fusioncache;fusion-cache;performance;async;ziggy
9 | ZiggyCreatures.Caching.Fusion.Backplane.Memory
10 | true
11 |
12 | - Change: better async support for subscribe/unsubscribe/publish
13 | - Update: package dependencies
14 |
15 | 1.0.0
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.Backplane.Memory/artwork/logo-128x128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/src/ZiggyCreatures.FusionCache.Backplane.Memory/artwork/logo-128x128.png
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.Backplane.Memory/docs/README.md:
--------------------------------------------------------------------------------
1 | # FusionCache
2 |
3 | 
4 |
5 | ### FusionCache is an easy to use, fast and robust hybrid cache with advanced resiliency features.
6 |
7 | It was born after years of dealing with all sorts of different types of caches: memory caching, distributed caching, http caching, CDNs, browser cache, offline cache, you name it. So I've tried to put together these experiences and came up with FusionCache.
8 |
9 | Find out [more](https://github.com/ZiggyCreatures/FusionCache).
10 |
11 | ## 📦 This package
12 |
13 | This package is an in-memory backplane implementation, eg: useful for testing.
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.Backplane.StackExchangeRedis/GlobalSuppressions.cs:
--------------------------------------------------------------------------------
1 | // This file is used by Code Analysis to maintain SuppressMessage
2 | // attributes that are applied to this project.
3 | // Project-level suppressions either have no target or are given
4 | // a specific target and scoped to a namespace, type, member, etc.
5 |
6 | using System.Diagnostics.CodeAnalysis;
7 |
8 | [assembly: SuppressMessage("Simplification", "RCS1049:Simplify boolean comparison.", Justification = "")]
9 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.Backplane.StackExchangeRedis/RedisBackplaneOptions.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 | using Microsoft.Extensions.Options;
3 | using StackExchange.Redis;
4 |
5 | namespace ZiggyCreatures.Caching.Fusion.Backplane.StackExchangeRedis;
6 |
7 | ///
8 | /// Represents the options available for the Redis backplane.
9 | ///
10 | public class RedisBackplaneOptions
11 | : IOptions
12 | {
13 | ///
14 | /// The configuration used to connect to Redis.
15 | ///
16 | public string? Configuration { get; set; }
17 |
18 | ///
19 | /// The configuration used to connect to Redis.
20 | /// This is preferred over Configuration.
21 | ///
22 | public ConfigurationOptions? ConfigurationOptions { get; set; }
23 |
24 | ///
25 | /// A delegate to create the ConnectionMultiplexer instance.
26 | ///
27 | public Func>? ConnectionMultiplexerFactory { get; set; }
28 |
29 | ///
30 | /// DEPRECATED: verify that at least one client received the notifications after each publish.
31 | ///
32 | [EditorBrowsable(EditorBrowsableState.Never)]
33 | [Obsolete("Please stop using this, it is now obsolete.", true)]
34 | public bool VerifyReceivedClientsCountAfterPublish { get; set; } = false;
35 |
36 | RedisBackplaneOptions IOptions.Value
37 | {
38 | get { return this; }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.Backplane.StackExchangeRedis/ZiggyCreatures.FusionCache.Backplane.StackExchangeRedis.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0;net8.0;net9.0
5 | 2.2.0
6 | ZiggyCreatures.FusionCache.Backplane.StackExchangeRedis
7 | FusionCache backplane for Redis based on the StackExchange.Redis library
8 | backplane;redis;stackexchange;caching;cache;hybrid;hybrid-cache;hybridcache;multi-level;multilevel;fusion;fusioncache;fusion-cache;performance;async;ziggy
9 | ZiggyCreatures.Caching.Fusion.Backplane.StackExchangeRedis
10 | true
11 |
12 | - Change: better async support for subscribe/unsubscribe/publish
13 | - Update: package dependencies
14 |
15 | 1.0.0
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.Backplane.StackExchangeRedis/artwork/logo-128x128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/src/ZiggyCreatures.FusionCache.Backplane.StackExchangeRedis/artwork/logo-128x128.png
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.Backplane.StackExchangeRedis/docs/README.md:
--------------------------------------------------------------------------------
1 | # FusionCache
2 |
3 | 
4 |
5 | ### FusionCache is an easy to use, fast and robust hybrid cache with advanced resiliency features.
6 |
7 | It was born after years of dealing with all sorts of different types of caches: memory caching, distributed caching, http caching, CDNs, browser cache, offline cache, you name it. So I've tried to put together these experiences and came up with FusionCache.
8 |
9 | Find out [more](https://github.com/ZiggyCreatures/FusionCache).
10 |
11 | ## 📦 This package
12 |
13 | This package is a backplane implementation on [Redis](https://redis.io/) based on the awesome [StackExchange.Redis](https://github.com/StackExchange/StackExchange.Redis) library.
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.Chaos/ChaosException.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Serialization;
2 |
3 | namespace ZiggyCreatures.Caching.Fusion.Chaos;
4 |
5 | ///
6 | /// The exception that is thrown when a method call should fail because of a randomized chaos event.
7 | ///
8 | [Serializable]
9 | public class ChaosException
10 | : InvalidOperationException
11 | {
12 | ///
13 | /// Initializes a new instance of the class.
14 | ///
15 | public ChaosException()
16 | {
17 | }
18 |
19 | /// Initializes a new instance of the class with a specified error message.
20 | /// The message that describes the error.
21 | public ChaosException(string? message)
22 | : base(message)
23 | {
24 | }
25 |
26 | /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception.
27 | /// The error message that explains the reason for the exception.
28 | /// The exception that is the cause of the current exception. If the innerException parameter is not a null reference (Nothing in Visual Basic), the current exception is raised in a catch block that handles the inner exception.
29 | public ChaosException(string? message, Exception? innerException)
30 | : base(message, innerException)
31 | {
32 | }
33 |
34 | /// Initializes a new instance of the class with serialized data.
35 | /// The object that holds the serialized object data.
36 | /// The contextual information about the source or destination.
37 | protected ChaosException(SerializationInfo info, StreamingContext context)
38 | : base(info, context)
39 | {
40 | }
41 | }
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.Chaos/ChaosMemoryCache.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Extensions.Caching.Memory;
2 | using Microsoft.Extensions.Logging;
3 | using ZiggyCreatures.Caching.Fusion.Chaos.Internals;
4 |
5 | namespace ZiggyCreatures.Caching.Fusion.Chaos;
6 |
7 | ///
8 | /// An implementation of that acts on behalf of another one, but with a (controllable) amount of chaos in-between.
9 | ///
10 | public class ChaosMemoryCache
11 | : AbstractChaosComponent
12 | , IMemoryCache
13 | {
14 | private readonly IMemoryCache _innerCache;
15 |
16 | ///
17 | /// Initializes a new instance of the ChaosMemoryCache class.
18 | ///
19 | /// The actual used if and when chaos does not happen.
20 | /// The logger to use, or .
21 | public ChaosMemoryCache(IMemoryCache innerCache, ILogger? logger = null)
22 | : base(logger)
23 | {
24 | _innerCache = innerCache ?? throw new ArgumentNullException(nameof(innerCache));
25 | }
26 |
27 | ///
28 | public ICacheEntry CreateEntry(object key)
29 | {
30 | MaybeChaos();
31 | return _innerCache.CreateEntry(key);
32 | }
33 |
34 | ///
35 | public void Dispose()
36 | {
37 | // EMPTY
38 | }
39 |
40 | ///
41 | public void Remove(object key)
42 | {
43 | MaybeChaos();
44 | _innerCache.Remove(key);
45 | }
46 |
47 | ///
48 | public bool TryGetValue(object key, out object? value)
49 | {
50 | MaybeChaos();
51 | return _innerCache.TryGetValue(key, out value);
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.Chaos/ChaosPlugin.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Extensions.Logging;
2 | using ZiggyCreatures.Caching.Fusion.Chaos.Internals;
3 | using ZiggyCreatures.Caching.Fusion.Plugins;
4 |
5 | namespace ZiggyCreatures.Caching.Fusion.Chaos;
6 |
7 | ///
8 | /// An implementation of with a (controllable) amount of chaos in-between.
9 | ///
10 | public class ChaosPlugin
11 | : AbstractChaosComponent
12 | , IFusionCachePlugin
13 | {
14 | private readonly IFusionCachePlugin _innerPlugin;
15 |
16 | ///
17 | /// Initializes a new instance of the ChaosPlugin class.
18 | ///
19 | /// The actual used if and when chaos does not happen.
20 | /// The logger to use, or .
21 | public ChaosPlugin(IFusionCachePlugin innerPlugin, ILogger? logger = null)
22 | : base(logger)
23 | {
24 | _innerPlugin = innerPlugin ?? throw new ArgumentNullException(nameof(innerPlugin));
25 | }
26 |
27 | ///
28 | public void Start(IFusionCache cache)
29 | {
30 | MaybeChaos();
31 | _innerPlugin.Start(cache);
32 | }
33 |
34 | ///
35 | public void Stop(IFusionCache cache)
36 | {
37 | MaybeChaos();
38 | _innerPlugin.Stop(cache);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.Chaos/GlobalSuppressions.cs:
--------------------------------------------------------------------------------
1 | // This file is used by Code Analysis to maintain SuppressMessage
2 | // attributes that are applied to this project.
3 | // Project-level suppressions either have no target or are given
4 | // a specific target and scoped to a namespace, type, member, etc.
5 |
6 | using System.Diagnostics.CodeAnalysis;
7 |
8 | [assembly: SuppressMessage("Style", "IDE0290:Use primary constructor")]
9 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.Chaos/ZiggyCreatures.FusionCache.Chaos.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | 2.2.0
6 | ZiggyCreatures.FusionCache.Chaos
7 | Chaos-related utilities and implementations of various componenets (like a distributed cache or a backplane), useful for things like testing dependent components' behavior in a controlled failing environment.
8 | chaos;caching;cache;hybrid;hybrid-cache;hybridcache;multi-level;multilevel;fusion;fusioncache;fusion-cache;performance;async;ziggy
9 | ZiggyCreatures.Caching.Fusion.Chaos
10 | true
11 |
12 | - Update: package dependencies
13 |
14 | 1.0.0
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.Chaos/artwork/logo-128x128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/src/ZiggyCreatures.FusionCache.Chaos/artwork/logo-128x128.png
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.Chaos/docs/README.md:
--------------------------------------------------------------------------------
1 | # FusionCache
2 |
3 | 
4 |
5 | ### FusionCache is an easy to use, fast and robust hybrid cache with advanced resiliency features.
6 |
7 | It was born after years of dealing with all sorts of different types of caches: memory caching, distributed caching, http caching, CDNs, browser cache, offline cache, you name it. So I've tried to put together these experiences and came up with FusionCache.
8 |
9 | Find out [more](https://github.com/ZiggyCreatures/FusionCache).
10 |
11 | ## 📦 This package
12 |
13 | This package contains [chaos-related](https://en.wikipedia.org/wiki/Chaos_engineering) utilities and implementations of various componenets (like a distributed cache or a backplane), useful for things like testing dependent components' behavior in a controlled failing environment.
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.Locking.AsyncKeyed/ZiggyCreatures.FusionCache.Locking.AsyncKeyed.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0;net8.0;net9.0
5 | 2.2.0
6 | ZiggyCreatures.FusionCache.Locking.AsyncKeyed
7 | FusionCache memory locker based on the AsyncKeyedLock library
8 | memory-locker;caching;cache;hybrid;hybrid-cache;hybridcache;multi-level;multilevel;fusion;fusioncache;fusion-cache;performance;async;ziggy
9 | ZiggyCreatures.Caching.Fusion.Locking.AsyncKeyed
10 | true
11 |
12 | - Initial release
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.Locking.AsyncKeyed/artwork/logo-128x128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/src/ZiggyCreatures.FusionCache.Locking.AsyncKeyed/artwork/logo-128x128.png
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.Locking.AsyncKeyed/docs/README.md:
--------------------------------------------------------------------------------
1 | # FusionCache
2 |
3 | 
4 |
5 | ### FusionCache is an easy to use, fast and robust hybrid cache with advanced resiliency features.
6 |
7 | It was born after years of dealing with all sorts of different types of caches: memory caching, distributed caching, http caching, CDNs, browser cache, offline cache, you name it. So I've tried to put together these experiences and came up with FusionCache.
8 |
9 | Find out [more](https://github.com/ZiggyCreatures/FusionCache).
10 |
11 | ## 📦 This package
12 |
13 | This package contains a memory locker implementation based on the [AsyncKeyedLock](https://github.com/MarkCiliaVincenti/AsyncKeyedLock) library.
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.MicrosoftHybridCache/ZiggyCreatures.FusionCache.MicrosoftHybridCache.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | 2.0.0-preview-4
6 | ZiggyCreatures.FusionCache.MicrosoftHybridCache
7 | An implementation of Microsoft's HybridCache based on FusionCache, for when you need to depend on the Microsoft abstraction, but want the power of FusionCache
8 | caching;cache;hybrid;hybrid-cache;hybridcache;multi-level;multilevel;fusion;fusioncache;fusion-cache;performance;async;ziggy
9 | ZiggyCreatures.Caching.Fusion.MicrosoftHybridCache
10 | true
11 |
12 | - Deprecation: this package is now empty: all related code moved to the main FusionCache package
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.MicrosoftHybridCache/artwork/logo-128x128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/src/ZiggyCreatures.FusionCache.MicrosoftHybridCache/artwork/logo-128x128.png
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.MicrosoftHybridCache/docs/README.md:
--------------------------------------------------------------------------------
1 | # FusionCache
2 |
3 | 
4 |
5 | ### FusionCache is an easy to use, fast and robust hybrid cache with advanced resiliency features.
6 |
7 | It was born after years of dealing with all sorts of different types of caches: memory caching, distributed caching, http caching, CDNs, browser cache, offline cache, you name it. So I've tried to put together these experiences and came up with FusionCache.
8 |
9 | Find out [more](https://github.com/ZiggyCreatures/FusionCache).
10 |
11 | ## 📦 This package
12 |
13 | ⚠️ IMPORTANT: this package has been deprecated since the related code has been moved into the main FusionCache package.
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.OpenTelemetry/FusionCacheMetricsInstrumentationOptions.cs:
--------------------------------------------------------------------------------
1 | namespace ZiggyCreatures.Caching.Fusion.OpenTelemetry;
2 |
3 | ///
4 | /// Represents the options available for the metrics instrumentation of FusionCache.
5 | ///
6 | public class FusionCacheMetricsInstrumentationOptions
7 | {
8 | ///
9 | /// Include metrics for the memory level. (default: )
10 | ///
11 | public bool IncludeMemoryLevel { get; set; } = false;
12 |
13 | ///
14 | /// Include metrics for the distributed level. (default: )
15 | ///
16 | public bool IncludeDistributedLevel { get; set; } = false;
17 |
18 | ///
19 | /// Include metrics for the backplane. (default: )
20 | ///
21 | public bool IncludeBackplane { get; set; } = false;
22 | }
23 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.OpenTelemetry/FusionCacheTracesInstrumentationOptions.cs:
--------------------------------------------------------------------------------
1 | namespace ZiggyCreatures.Caching.Fusion.OpenTelemetry;
2 |
3 | ///
4 | /// Represents the options available for the traces instrumentation of FusionCache.
5 | ///
6 | public class FusionCacheTracesInstrumentationOptions
7 | {
8 | ///
9 | /// Include traces for the memory level. (default: )
10 | ///
11 | public bool IncludeMemoryLevel { get; set; } = false;
12 |
13 | ///
14 | /// Include traces for the distributed level. (default: )
15 | ///
16 | public bool IncludeDistributedLevel { get; set; } = true;
17 |
18 | ///
19 | /// Include traces for the backplane. (default: )
20 | ///
21 | public bool IncludeBackplane { get; set; } = false;
22 | }
23 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.OpenTelemetry/MeterProviderBuilderExtensions.cs:
--------------------------------------------------------------------------------
1 | using ZiggyCreatures.Caching.Fusion;
2 | using ZiggyCreatures.Caching.Fusion.OpenTelemetry;
3 |
4 | namespace OpenTelemetry.Metrics;
5 |
6 | ///
7 | /// Contains extension methods to for enabling FusionCache metrics instrumentation.
8 | ///
9 | public static class MeterProviderBuilderExtensions
10 | {
11 | ///
12 | /// Enable metrics instrumentation for FusionCache.
13 | ///
14 | /// being configured.
15 | /// Callback action for configuring the available options.
16 | /// The instance of to chain the calls.
17 | public static MeterProviderBuilder AddFusionCacheInstrumentation(this MeterProviderBuilder builder, Action? configure = null)
18 | {
19 | if (builder is null)
20 | throw new ArgumentNullException(nameof(builder));
21 |
22 | var options = new FusionCacheMetricsInstrumentationOptions();
23 | configure?.Invoke(options);
24 |
25 | builder.AddMeter(FusionCacheDiagnostics.MeterName);
26 | if (options.IncludeMemoryLevel)
27 | builder.AddMeter(FusionCacheDiagnostics.MeterNameMemoryLevel);
28 | if (options.IncludeDistributedLevel)
29 | builder.AddMeter(FusionCacheDiagnostics.MeterNameDistributedLevel);
30 | if (options.IncludeBackplane)
31 | builder.AddMeter(FusionCacheDiagnostics.MeterNameBackplane);
32 |
33 | return builder;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.OpenTelemetry/TracerProviderBuilderExtensions.cs:
--------------------------------------------------------------------------------
1 | using ZiggyCreatures.Caching.Fusion;
2 | using ZiggyCreatures.Caching.Fusion.OpenTelemetry;
3 |
4 | namespace OpenTelemetry.Trace;
5 |
6 | ///
7 | /// Contains extension methods to for enabling FusionCache traces instrumentation.
8 | ///
9 | public static class TracerProviderBuilderExtensions
10 | {
11 | ///
12 | /// Enable traces instrumentation for FusionCache.
13 | ///
14 | /// being configured.
15 | /// Callback action for configuring the available options.
16 | /// The instance of to chain the calls.
17 | public static TracerProviderBuilder AddFusionCacheInstrumentation(this TracerProviderBuilder builder, Action? configure = null)
18 | {
19 | if (builder is null)
20 | throw new ArgumentNullException(nameof(builder));
21 |
22 | var options = new FusionCacheTracesInstrumentationOptions();
23 | configure?.Invoke(options);
24 |
25 | builder.AddSource(FusionCacheDiagnostics.ActivitySourceName);
26 | if (options.IncludeMemoryLevel)
27 | builder.AddSource(FusionCacheDiagnostics.ActivitySourceNameMemoryLevel);
28 | if (options.IncludeDistributedLevel)
29 | builder.AddSource(FusionCacheDiagnostics.ActivitySourceNameDistributedLevel);
30 | if (options.IncludeBackplane)
31 | builder.AddSource(FusionCacheDiagnostics.ActivitySourceNameBackplane);
32 |
33 | return builder;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.OpenTelemetry/ZiggyCreatures.FusionCache.OpenTelemetry.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | 2.2.0
6 | ZiggyCreatures.FusionCache.OpenTelemetry
7 | Add native OpenTelemetry support to FusionCache.
8 | telemetry;observability;opentelemetry;open-telemetry;chaos;caching;cache;hybrid;hybrid-cache;hybridcache;multi-level;multilevel;fusion;fusioncache;fusion-cache;performance;async;ziggy
9 | ZiggyCreatures.Caching.Fusion.OpenTelemetry
10 | true
11 |
12 | - Update: package dependencies
13 |
14 | 1.0.0
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.OpenTelemetry/artwork/logo-128x128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/src/ZiggyCreatures.FusionCache.OpenTelemetry/artwork/logo-128x128.png
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.OpenTelemetry/docs/README.md:
--------------------------------------------------------------------------------
1 | # FusionCache
2 |
3 | 
4 |
5 | ### FusionCache is an easy to use, fast and robust hybrid cache with advanced resiliency features.
6 |
7 | It was born after years of dealing with all sorts of different types of caches: memory caching, distributed caching, http caching, CDNs, browser cache, offline cache, you name it. So I've tried to put together these experiences and came up with FusionCache.
8 |
9 | Find out [more](https://github.com/ZiggyCreatures/FusionCache).
10 |
11 | ## 📦 This package
12 |
13 | This package adds native [OpenTelemetry](https://opentelemetry.io/) instrumentation to FusionCache.
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.Serialization.CysharpMemoryPack/ZiggyCreatures.FusionCache.Serialization.CysharpMemoryPack.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.1;net7.0;net8.0
5 | 2.2.0
6 | ZiggyCreatures.FusionCache.Serialization.CysharpMemoryPack
7 | FusionCache serializer based on Cysharp's MemoryPack serializer
8 | memorypack;caching;cache;hybrid;hybrid-cache;hybridcache;multi-level;multilevel;fusion;fusioncache;fusion-cache;performance;async;ziggy;cache-stampede
9 | ZiggyCreatures.Caching.Fusion.Serialization.CysharpMemoryPack
10 | true
11 |
12 | - Update: package dependencies
13 |
14 | 1.0.0
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.Serialization.CysharpMemoryPack/artwork/logo-128x128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/src/ZiggyCreatures.FusionCache.Serialization.CysharpMemoryPack/artwork/logo-128x128.png
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.Serialization.CysharpMemoryPack/docs/README.md:
--------------------------------------------------------------------------------
1 | # FusionCache
2 |
3 | 
4 |
5 | ### FusionCache is an easy to use, fast and robust hybrid cache with advanced resiliency features.
6 |
7 | It was born after years of dealing with all sorts of different types of caches: memory caching, distributed caching, http caching, CDNs, browser cache, offline cache, you name it. So I've tried to put together these experiences and came up with FusionCache.
8 |
9 | Find out [more](https://github.com/ZiggyCreatures/FusionCache).
10 |
11 | ## 📦 This package
12 |
13 | This package is an implementation for a FusionCache serializer to be used with the optional distributed cache level, based on the uber fast new serializer [MemoryPack](https://github.com/Cysharp/MemoryPack).
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.Serialization.NeueccMessagePack/ZiggyCreatures.FusionCache.Serialization.NeueccMessagePack.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0;net7.0;net8.0
5 | 2.2.0
6 | ZiggyCreatures.FusionCache.Serialization.NeueccMessagePack
7 | FusionCache serializer based on Neuecc's MessagePack serializer
8 | messagepack;msgpack;caching;cache;hybrid;hybrid-cache;hybridcache;multi-level;multilevel;fusion;fusioncache;fusion-cache;performance;async;ziggy;cache-stampede
9 | ZiggyCreatures.Caching.Fusion.Serialization.NeueccMessagePack
10 | true
11 |
12 | - Update: package dependencies
13 |
14 | 1.0.0
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.Serialization.NeueccMessagePack/artwork/logo-128x128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/src/ZiggyCreatures.FusionCache.Serialization.NeueccMessagePack/artwork/logo-128x128.png
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.Serialization.NeueccMessagePack/docs/README.md:
--------------------------------------------------------------------------------
1 | # FusionCache
2 |
3 | 
4 |
5 | ### FusionCache is an easy to use, fast and robust hybrid cache with advanced resiliency features.
6 |
7 | It was born after years of dealing with all sorts of different types of caches: memory caching, distributed caching, http caching, CDNs, browser cache, offline cache, you name it. So I've tried to put together these experiences and came up with FusionCache.
8 |
9 | Find out [more](https://github.com/ZiggyCreatures/FusionCache).
10 |
11 | ## 📦 This package
12 |
13 | This package is an implementation for a FusionCache serializer to be used with the optional distributed cache level, based on the famous [Neuecc's MessagePack](https://github.com/neuecc/MessagePack-CSharp).
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.Serialization.NewtonsoftJson/ZiggyCreatures.FusionCache.Serialization.NewtonsoftJson.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | 2.2.0
6 | ZiggyCreatures.FusionCache.Serialization.NewtonsoftJson
7 | FusionCache serializer based on Newtonsoft Json.NET
8 | json;caching;cache;hybrid;hybrid-cache;hybridcache;multi-level;multilevel;fusion;fusioncache;fusion-cache;performance;async;ziggy;cache-stampede
9 | ZiggyCreatures.Caching.Fusion.Serialization.NewtonsoftJson
10 | true
11 |
12 | - Update: package dependencies
13 |
14 | 1.0.0
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.Serialization.NewtonsoftJson/artwork/logo-128x128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/src/ZiggyCreatures.FusionCache.Serialization.NewtonsoftJson/artwork/logo-128x128.png
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.Serialization.NewtonsoftJson/docs/README.md:
--------------------------------------------------------------------------------
1 | # FusionCache
2 |
3 | 
4 |
5 | ### FusionCache is an easy to use, fast and robust hybrid cache with advanced resiliency features.
6 |
7 | It was born after years of dealing with all sorts of different types of caches: memory caching, distributed caching, http caching, CDNs, browser cache, offline cache, you name it. So I've tried to put together these experiences and came up with FusionCache.
8 |
9 | Find out [more](https://github.com/ZiggyCreatures/FusionCache).
10 |
11 | ## 📦 This package
12 |
13 | This package is an implementation for a FusionCache serializer to be used with the optional distributed cache level, based on [Newtonsoft Json.NET](https://www.newtonsoft.com/json).
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.Serialization.ProtoBufNet/Internals/FusionCacheEntryMetadataSurrogate.cs:
--------------------------------------------------------------------------------
1 | using ProtoBuf;
2 | using ZiggyCreatures.Caching.Fusion.Internals;
3 |
4 | namespace ZiggyCreatures.Caching.Fusion.Serialization.ProtoBufNet.Internals;
5 |
6 | [ProtoContract]
7 | internal class FusionCacheEntryMetadataSurrogate
8 | {
9 | [ProtoMember(1)]
10 | public bool IsStale { get; set; }
11 |
12 | [ProtoMember(2)]
13 | public long? LastModifiedTimestamp { get; set; }
14 |
15 | [ProtoMember(3)]
16 | public string? ETag { get; set; }
17 |
18 | [ProtoMember(4)]
19 | public long? EagerExpirationTimestamp { get; set; }
20 |
21 | [ProtoMember(5)]
22 | public long? Size { get; set; }
23 |
24 | [ProtoMember(6)]
25 | public byte? Priority { get; set; }
26 |
27 | public static implicit operator FusionCacheEntryMetadataSurrogate?(FusionCacheEntryMetadata value)
28 | {
29 | if (value is null)
30 | return null;
31 |
32 | return new FusionCacheEntryMetadataSurrogate
33 | {
34 | IsStale = value.IsStale,
35 | EagerExpirationTimestamp = value.EagerExpirationTimestamp,
36 | ETag = value.ETag,
37 | LastModifiedTimestamp = value.LastModifiedTimestamp,
38 | Size = value.Size,
39 | Priority = value.Priority
40 | };
41 | }
42 |
43 | public static implicit operator FusionCacheEntryMetadata?(FusionCacheEntryMetadataSurrogate value)
44 | {
45 | if (value is null)
46 | return null;
47 |
48 | return new FusionCacheEntryMetadata(
49 | value.IsStale,
50 | value.EagerExpirationTimestamp,
51 | value.ETag,
52 | value.LastModifiedTimestamp,
53 | value.Size,
54 | value.Priority
55 | );
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.Serialization.ProtoBufNet/ZiggyCreatures.FusionCache.Serialization.ProtoBufNet.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | 2.2.0
6 | ZiggyCreatures.FusionCache.Serialization.ProtoBufNet
7 | FusionCache serializer based on protobuf-net
8 | protobuf;caching;cache;hybrid;hybrid-cache;hybridcache;multi-level;multilevel;fusion;fusioncache;fusion-cache;performance;async;ziggy
9 | ZiggyCreatures.Caching.Fusion.Serialization.ProtoBufNet
10 | true
11 |
12 | - Update: package dependencies
13 |
14 | 1.0.0
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.Serialization.ProtoBufNet/artwork/logo-128x128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/src/ZiggyCreatures.FusionCache.Serialization.ProtoBufNet/artwork/logo-128x128.png
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.Serialization.ProtoBufNet/docs/README.md:
--------------------------------------------------------------------------------
1 | # FusionCache
2 |
3 | 
4 |
5 | ### FusionCache is an easy to use, fast and robust hybrid cache with advanced resiliency features.
6 |
7 | It was born after years of dealing with all sorts of different types of caches: memory caching, distributed caching, http caching, CDNs, browser cache, offline cache, you name it. So I've tried to put together these experiences and came up with FusionCache.
8 |
9 | Find out [more](https://github.com/ZiggyCreatures/FusionCache).
10 |
11 | ## 📦 This package
12 |
13 | This package is an implementation for a FusionCache serializer to be used with the optional distributed cache level, based on [protobuf-net](https://github.com/protobuf-net/protobuf-net), one of the most used Protobuf serializer on .NET.
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.Serialization.ServiceStackJson/ZiggyCreatures.FusionCache.Serialization.ServiceStackJson.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | 2.2.0
6 | ZiggyCreatures.FusionCache.Serialization.ServiceStackJson
7 | FusionCache serializer based on ServiceStack's Json serializer
8 | json;caching;cache;hybrid;hybrid-cache;hybridcache;multi-level;multilevel;fusion;fusioncache;fusion-cache;performance;async;ziggy;cache-stampede
9 | ZiggyCreatures.Caching.Fusion.Serialization.ServiceStackJson
10 | true
11 |
12 | - Update: package dependencies
13 |
14 | 1.0.0
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.Serialization.ServiceStackJson/artwork/logo-128x128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/src/ZiggyCreatures.FusionCache.Serialization.ServiceStackJson/artwork/logo-128x128.png
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.Serialization.ServiceStackJson/docs/README.md:
--------------------------------------------------------------------------------
1 | # FusionCache
2 |
3 | 
4 |
5 | ### FusionCache is an easy to use, fast and robust hybrid cache with advanced resiliency features.
6 |
7 | It was born after years of dealing with all sorts of different types of caches: memory caching, distributed caching, http caching, CDNs, browser cache, offline cache, you name it. So I've tried to put together these experiences and came up with FusionCache.
8 |
9 | Find out [more](https://github.com/ZiggyCreatures/FusionCache).
10 |
11 | ## 📦 This package
12 |
13 | This package is an implementation for a FusionCache serializer to be used with the optional distributed cache level, based on the JSON serializer by [ServiceStack](https://docs.servicestack.net/json-format).
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.Serialization.SystemTextJson/ZiggyCreatures.FusionCache.Serialization.SystemTextJson.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | 2.2.0
6 | ZiggyCreatures.FusionCache.Serialization.SystemTextJson
7 | FusionCache serializer based on System.Text.Json
8 | json;caching;cache;hybrid;hybrid-cache;hybridcache;multi-level;multilevel;fusion;fusioncache;fusion-cache;performance;async;ziggy
9 | ZiggyCreatures.Caching.Fusion.Serialization.SystemTextJson
10 | true
11 |
12 | - Update: package dependencies
13 |
14 | 1.0.0
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.Serialization.SystemTextJson/artwork/logo-128x128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ZiggyCreatures/FusionCache/2473560bf14a99411947a13ae3c40b41684c3fa7/src/ZiggyCreatures.FusionCache.Serialization.SystemTextJson/artwork/logo-128x128.png
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache.Serialization.SystemTextJson/docs/README.md:
--------------------------------------------------------------------------------
1 | # FusionCache
2 |
3 | 
4 |
5 | ### FusionCache is an easy to use, fast and robust hybrid cache with advanced resiliency features.
6 |
7 | It was born after years of dealing with all sorts of different types of caches: memory caching, distributed caching, http caching, CDNs, browser cache, offline cache, you name it. So I've tried to put together these experiences and came up with FusionCache.
8 |
9 | Find out [more](https://github.com/ZiggyCreatures/FusionCache).
10 |
11 | ## 📦 This package
12 |
13 | This package is an implementation for a FusionCache serializer to be used with the optional distributed cache level, based on [System.Text.Json](https://docs.microsoft.com/en-us/dotnet/standard/serialization/system-text-json-how-to).
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache/Backplane/BackplaneConnectionInfo.cs:
--------------------------------------------------------------------------------
1 | namespace ZiggyCreatures.Caching.Fusion.Backplane;
2 |
3 | ///
4 | /// A struct containing information about a backplane connection or re-connection.
5 | ///
6 | public class BackplaneConnectionInfo
7 | {
8 | ///
9 | /// Creates a new instance.
10 | ///
11 | ///
12 | public BackplaneConnectionInfo(bool isReconnection)
13 | {
14 | IsReconnection = isReconnection;
15 | }
16 |
17 | ///
18 | /// If set to , the connection is a re-connection.
19 | ///
20 | public bool IsReconnection { get; }
21 | }
22 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache/Backplane/BackplaneMessageAction.cs:
--------------------------------------------------------------------------------
1 | namespace ZiggyCreatures.Caching.Fusion.Backplane;
2 |
3 | ///
4 | /// The type of action for a backplane message.
5 | ///
6 | public enum BackplaneMessageAction : byte
7 | {
8 | ///
9 | /// Unknown action.
10 | ///
11 | Unknown = 0,
12 | ///
13 | /// A cache entry has been set (via either a Set() or a GetOrSet() method call).
14 | ///
15 | EntrySet = 1,
16 | ///
17 | /// A cache entry has been removed (via a Remove() method call).
18 | ///
19 | EntryRemove = 2,
20 | ///
21 | /// A cache entry has been manually expired (via an Expire() method call).
22 | ///
23 | EntryExpire = 3
24 | }
25 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache/Backplane/IFusionCacheBackplane.cs:
--------------------------------------------------------------------------------
1 | namespace ZiggyCreatures.Caching.Fusion.Backplane;
2 |
3 | ///
4 | /// The core interface to create a FusionCache backplane.
5 | ///
6 | public interface IFusionCacheBackplane
7 | {
8 | ///
9 | /// Subscribe to receive messages from other nodes.
10 | ///
11 | /// The backplane subscription options.
12 | void Subscribe(BackplaneSubscriptionOptions options);
13 |
14 | ///
15 | /// Subscribe to receive messages from other nodes.
16 | ///
17 | /// The backplane subscription options.
18 | ValueTask SubscribeAsync(BackplaneSubscriptionOptions options);
19 |
20 | ///
21 | /// Unsubscribe from receiving messages from other nodes.
22 | ///
23 | void Unsubscribe();
24 |
25 | ///
26 | /// Unsubscribe from receiving messages from other nodes.
27 | ///
28 | ValueTask UnsubscribeAsync();
29 |
30 | ///
31 | /// Send a notification to the other connected nodes, if any.
32 | ///
33 | /// The message to send.
34 | /// The options to use.
35 | /// An optional to cancel the operation.
36 | ValueTask PublishAsync(BackplaneMessage message, FusionCacheEntryOptions options, CancellationToken token = default);
37 |
38 | ///
39 | /// Send a notification to the other connected nodes, if any.
40 | ///
41 | /// The message to send.
42 | /// The options to use.
43 | /// An optional to cancel the operation.
44 | void Publish(BackplaneMessage message, FusionCacheEntryOptions options, CancellationToken token = default);
45 | }
46 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache/CacheKeyModifierMode.cs:
--------------------------------------------------------------------------------
1 | namespace ZiggyCreatures.Caching.Fusion;
2 |
3 | ///
4 | /// The mode in which a cache modifier should be used to produce a cache key.
5 | ///
6 | public enum CacheKeyModifierMode
7 | {
8 | ///
9 | /// The cache modifier will be prepended, plus a separator.
10 | ///
11 | Prefix = 0,
12 | ///
13 | /// The cache modifier will be appended, plus a separator.
14 | ///
15 | Suffix = 1,
16 | ///
17 | /// The cache modifier will not be prepended.
18 | ///
19 | None = 2
20 | }
21 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache/DangerZone/FusionCacheDangerZoneUtils.cs:
--------------------------------------------------------------------------------
1 | namespace ZiggyCreatures.Caching.Fusion.DangerZone;
2 |
3 | ///
4 | /// Utilities and extension methods that are dangerous to use, but may somehow be useful although only in some very very rare scenarios.
5 | ///
6 | /// ⚠️ WARNING: please, use with great care and only if you are really sure.
7 | ///
8 | public static class FusionCacheDangerZoneUtils
9 | {
10 | ///
11 | /// Set the InstanceId of the cache, but please don't use this.
12 | ///
13 | /// ⚠ WARNING: again, this should NOT be set, basically never ever, unless you really know what you are doing. For example by using the same value for two different cache instances they will be considered as the same cache instance, and this will lead to critical errors. So again, really: you should not use this.
14 | ///
15 | ///
16 | /// The value for .
17 | public static void SetInstanceId(this FusionCacheOptions options, string instanceId)
18 | {
19 | options.SetInstanceIdInternal(instanceId);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache/Events/FusionCacheAbstractEventsHub.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Extensions.Logging;
2 |
3 | namespace ZiggyCreatures.Caching.Fusion.Events;
4 |
5 | ///
6 | /// An abstract class with base plumbing.
7 | ///
8 | public abstract class FusionCacheAbstractEventsHub
9 | {
10 | ///
11 | /// The instance.
12 | ///
13 | protected IFusionCache _cache;
14 |
15 | ///
16 | /// The instance.
17 | ///
18 | protected readonly FusionCacheOptions _options;
19 |
20 | ///
21 | /// The instance.
22 | ///
23 | protected readonly ILogger? _logger;
24 |
25 | ///
26 | /// The for errors during event handling.
27 | ///
28 | protected LogLevel _errorsLogLevel;
29 |
30 | ///
31 | /// The execution mode for event handlers.
32 | ///
33 | protected bool _syncExecution;
34 |
35 | ///
36 | /// Initializes a new instance of the class.
37 | ///
38 | /// The instance.
39 | /// The instance.
40 | /// The instance.
41 | protected FusionCacheAbstractEventsHub(IFusionCache cache, FusionCacheOptions options, ILogger? logger)
42 | {
43 | _cache = cache;
44 | _options = options;
45 | _logger = logger;
46 |
47 | _errorsLogLevel = _options.EventHandlingErrorsLogLevel;
48 | _syncExecution = _options.EnableSyncEventHandlersExecution;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache/Events/FusionCacheBackplaneMessageEventArgs.cs:
--------------------------------------------------------------------------------
1 | using ZiggyCreatures.Caching.Fusion.Backplane;
2 |
3 | namespace ZiggyCreatures.Caching.Fusion.Events;
4 |
5 | ///
6 | /// The specific object for events related to backplane messages, either published or received.
7 | ///
8 | public class FusionCacheBackplaneMessageEventArgs : EventArgs
9 | {
10 | ///
11 | /// Initializes a new instance of the class.
12 | ///
13 | /// The backplane message.
14 | public FusionCacheBackplaneMessageEventArgs(BackplaneMessage message)
15 | {
16 | Message = message;
17 | }
18 |
19 | ///
20 | /// The backplane message.
21 | ///
22 | public BackplaneMessage Message { get; }
23 | }
24 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache/Events/FusionCacheCircuitBreakerChangeEventArgs.cs:
--------------------------------------------------------------------------------
1 | namespace ZiggyCreatures.Caching.Fusion.Events;
2 |
3 | ///
4 | /// The specific object for events related to opening/closing of a circuit breaker.
5 | ///
6 | public class FusionCacheCircuitBreakerChangeEventArgs : EventArgs
7 | {
8 | ///
9 | /// Initializes a new instance of the class.
10 | ///
11 | /// A flag that indicates if the circuit breaker has been opened or closed.
12 | public FusionCacheCircuitBreakerChangeEventArgs(bool isClosed)
13 | {
14 | IsClosed = isClosed;
15 | }
16 |
17 | ///
18 | /// A flag that indicates if the circuit breaker has been opened or closed.
19 | ///
20 | public bool IsClosed { get; }
21 | }
22 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache/Events/FusionCacheEntryEventArgs.cs:
--------------------------------------------------------------------------------
1 | namespace ZiggyCreatures.Caching.Fusion.Events;
2 |
3 | ///
4 | /// The specific object for events related to cache entries (eg: with a cache key).
5 | ///
6 | public class FusionCacheEntryEventArgs : EventArgs
7 | {
8 | ///
9 | /// Initializes a new instance of the class.
10 | ///
11 | /// The cache key related to the event.
12 | public FusionCacheEntryEventArgs(string key)
13 | {
14 | Key = key;
15 | }
16 |
17 | ///
18 | /// The cache key related to the event.
19 | ///
20 | public string Key { get; }
21 | }
22 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache/Events/FusionCacheEntryEvictionEventArgs.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Extensions.Caching.Memory;
2 |
3 | namespace ZiggyCreatures.Caching.Fusion.Events;
4 |
5 | ///
6 | /// The specific object for events related to cache entries' evictions.
7 | ///
8 | public class FusionCacheEntryEvictionEventArgs
9 | : FusionCacheEntryEventArgs
10 | {
11 | ///
12 | /// Initializes a new instance of the class.
13 | ///
14 | /// The cache key related to the event.
15 | /// The reason for the eviction.
16 | /// The value being evicted from the cache.
17 | public FusionCacheEntryEvictionEventArgs(string key, EvictionReason reason, object? value)
18 | : base(key)
19 | {
20 | Reason = reason;
21 | Value = value;
22 | }
23 |
24 | ///
25 | /// The reason for the eviction.
26 | ///
27 | public EvictionReason Reason { get; }
28 |
29 | ///
30 | /// The value being evicted from the cache.
31 | ///
32 | public object? Value { get; }
33 | }
34 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache/Events/FusionCacheEntryHitEventArgs.cs:
--------------------------------------------------------------------------------
1 | namespace ZiggyCreatures.Caching.Fusion.Events;
2 |
3 | ///
4 | /// The specific object for events related to cache entries' hits (eg: with a cache key and a stale flag).
5 | ///
6 | public class FusionCacheEntryHitEventArgs : FusionCacheEntryEventArgs
7 | {
8 | ///
9 | /// Initializes a new instance of the class.
10 | ///
11 | /// The cache key related to the event.
12 | /// A flag that indicates if the cache hit was for a fresh or stale entry.
13 | public FusionCacheEntryHitEventArgs(string key, bool isStale)
14 | : base(key)
15 | {
16 | IsStale = isStale;
17 | }
18 |
19 | ///
20 | /// A flag that indicates if the cache hit was for a fresh or stale entry.
21 | ///
22 | public bool IsStale { get; }
23 | }
24 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache/Events/FusionCacheTagEventArgs.cs:
--------------------------------------------------------------------------------
1 | namespace ZiggyCreatures.Caching.Fusion.Events;
2 |
3 | ///
4 | /// The specific object for events related to tag operations (eg: RemoveByTag).
5 | ///
6 | public class FusionCacheTagEventArgs : EventArgs
7 | {
8 | ///
9 | /// Initializes a new instance of the class.
10 | ///
11 | /// The cache key related to the event.
12 | public FusionCacheTagEventArgs(string tag)
13 | {
14 | Tag = tag;
15 | }
16 |
17 | ///
18 | /// The cache key related to the event.
19 | ///
20 | public string Tag { get; }
21 | }
22 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache/FusionCacheBackplaneException.cs:
--------------------------------------------------------------------------------
1 | namespace ZiggyCreatures.Caching.Fusion;
2 |
3 | ///
4 | /// The generic exception that is thrown when a distributed cache error occurs: the InnerException contains the original exception.
5 | ///
6 | [Serializable]
7 | public class FusionCacheBackplaneException
8 | : Exception
9 | {
10 | ///
11 | /// Initializes a new instance of the class.
12 | ///
13 | public FusionCacheBackplaneException()
14 | {
15 | }
16 |
17 | /// Initializes a new instance of the class with a specified error message.
18 | /// The message that describes the error.
19 | public FusionCacheBackplaneException(string? message)
20 | : base(message)
21 | {
22 | }
23 |
24 | /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception.
25 | /// The error message that explains the reason for the exception.
26 | /// The exception that is the cause of the current exception. If the innerException parameter is not a null reference (Nothing in Visual Basic), the current exception is raised in a catch block that handles the inner exception.
27 | public FusionCacheBackplaneException(string? message, Exception? innerException)
28 | : base(message, innerException)
29 | {
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache/FusionCacheDiagnostics.cs:
--------------------------------------------------------------------------------
1 | namespace ZiggyCreatures.Caching.Fusion;
2 |
3 | ///
4 | /// A support class for FusionCache diagnostics.
5 | ///
6 | public static class FusionCacheDiagnostics
7 | {
8 | ///
9 | /// The current version of FusionCache.
10 | ///
11 | public const string FusionCacheVersion = "2.2.0";
12 |
13 | ///
14 | /// The activity source name for FusionCache.
15 | ///
16 | public const string ActivitySourceName = "ZiggyCreatures.Caching.Fusion";
17 |
18 | ///
19 | /// The activity source name for the FusionCache memory level.
20 | ///
21 | public const string ActivitySourceNameMemoryLevel = "ZiggyCreatures.Caching.Fusion.Memory";
22 |
23 | ///
24 | /// The activity source name for the FusionCache distributed level.
25 | ///
26 | public const string ActivitySourceNameDistributedLevel = "ZiggyCreatures.Caching.Fusion.Distributed";
27 |
28 | ///
29 | /// The activity source name for the FusionCache backplane.
30 | ///
31 | public const string ActivitySourceNameBackplane = "ZiggyCreatures.Caching.Fusion.Backplane";
32 |
33 |
34 | ///
35 | /// The meter name for FusionCache.
36 | ///
37 | public const string MeterName = "ZiggyCreatures.Caching.Fusion";
38 |
39 | ///
40 | /// The meter name for the FusionCache memory level.
41 | ///
42 | public const string MeterNameMemoryLevel = "ZiggyCreatures.Caching.Fusion.Memory";
43 |
44 | ///
45 | /// The meter name for the FusionCache distributed level.
46 | ///
47 | public const string MeterNameDistributedLevel = "ZiggyCreatures.Caching.Fusion.Distributed";
48 |
49 | ///
50 | /// The meter name for the FusionCache backplane.
51 | ///
52 | public const string MeterNameBackplane = "ZiggyCreatures.Caching.Fusion.Backplane";
53 | }
54 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache/FusionCacheDistributedCacheException.cs:
--------------------------------------------------------------------------------
1 | namespace ZiggyCreatures.Caching.Fusion;
2 |
3 | ///
4 | /// The generic exception that is thrown when a distributed cache error occurs: the InnerException contains the original exception.
5 | ///
6 | [Serializable]
7 | public class FusionCacheDistributedCacheException
8 | : Exception
9 | {
10 | ///
11 | /// Initializes a new instance of the class.
12 | ///
13 | public FusionCacheDistributedCacheException()
14 | {
15 | }
16 |
17 | /// Initializes a new instance of the class with a specified error message.
18 | /// The message that describes the error.
19 | public FusionCacheDistributedCacheException(string? message)
20 | : base(message)
21 | {
22 | }
23 |
24 | /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception.
25 | /// The error message that explains the reason for the exception.
26 | /// The exception that is the cause of the current exception. If the innerException parameter is not a null reference (Nothing in Visual Basic), the current exception is raised in a catch block that handles the inner exception.
27 | public FusionCacheDistributedCacheException(string? message, Exception? innerException)
28 | : base(message, innerException)
29 | {
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache/FusionCacheExtMethods.cs:
--------------------------------------------------------------------------------
1 | namespace ZiggyCreatures.Caching.Fusion;
2 |
3 | ///
4 | /// A set of extension methods that add some commonly used overloads to any instance of a instance and other common objects.
5 | ///
6 | public static partial class FusionCacheExtMethods
7 | {
8 | #region Dependency Injection
9 |
10 | ///
11 | /// Returns the default FusionCache instance, the one with the CacheName equals to .
12 | ///
13 | /// The default FusionCache instance.
14 | public static IFusionCache GetDefaultCache(this IFusionCacheProvider cacheProvider)
15 | {
16 | return cacheProvider.GetCache(FusionCacheOptions.DefaultCacheName);
17 | }
18 |
19 | ///
20 | /// Returns the default FusionCache instance, the one with the CacheName equals to , or if none found.
21 | ///
22 | /// The default FusionCache instance.
23 | public static IFusionCache? GetDefaultCacheOrNull(this IFusionCacheProvider cacheProvider)
24 | {
25 | return cacheProvider.GetCacheOrNull(FusionCacheOptions.DefaultCacheName);
26 | }
27 |
28 | #endregion
29 | }
30 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache/FusionCacheFactoryException.cs:
--------------------------------------------------------------------------------
1 | namespace ZiggyCreatures.Caching.Fusion;
2 |
3 | ///
4 | /// The exception thrown when a factory fails via the Fail() method and fail-safe was not enabled or possible.
5 | ///
6 | [Serializable]
7 | public class FusionCacheFactoryException
8 | : Exception
9 | {
10 | ///
11 | /// Initializes a new instance of the class.
12 | ///
13 | public FusionCacheFactoryException()
14 | {
15 | }
16 |
17 | /// Initializes a new instance of the class with a specified error message.
18 | /// The message that describes the error.
19 | public FusionCacheFactoryException(string? message)
20 | : base(message)
21 | {
22 | }
23 |
24 | /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception.
25 | /// The error message that explains the reason for the exception.
26 | /// The exception that is the cause of the current exception. If the innerException parameter is not a null reference (Nothing in Visual Basic), the current exception is raised in a catch block that handles the inner exception.
27 | public FusionCacheFactoryException(string? message, FusionCacheFactoryException? innerException)
28 | : base(message, innerException)
29 | {
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache/FusionCacheInvalidOptionsException.cs:
--------------------------------------------------------------------------------
1 | namespace ZiggyCreatures.Caching.Fusion;
2 |
3 | ///
4 | /// The generic exception that is thrown when a distributed cache error occurs: the InnerException contains the original exception.
5 | ///
6 | [Serializable]
7 | public class FusionCacheInvalidOptionsException
8 | : Exception
9 | {
10 | ///
11 | /// Initializes a new instance of the class.
12 | ///
13 | public FusionCacheInvalidOptionsException()
14 | {
15 | }
16 |
17 | /// Initializes a new instance of the class with a specified error message.
18 | /// The message that describes the error.
19 | public FusionCacheInvalidOptionsException(string? message)
20 | : base(message)
21 | {
22 | }
23 |
24 | /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception.
25 | /// The error message that explains the reason for the exception.
26 | /// The exception that is the cause of the current exception. If the innerException parameter is not a null reference (Nothing in Visual Basic), the current exception is raised in a catch block that handles the inner exception.
27 | public FusionCacheInvalidOptionsException(string? message, Exception? innerException)
28 | : base(message, innerException)
29 | {
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache/FusionCacheSerializationException.cs:
--------------------------------------------------------------------------------
1 | namespace ZiggyCreatures.Caching.Fusion;
2 |
3 | ///
4 | /// The generic exception that is thrown when a serialization error occurs: the InnerException contains the original exception.
5 | ///
6 | [Serializable]
7 | public class FusionCacheSerializationException
8 | : InvalidOperationException
9 | {
10 | ///
11 | /// Initializes a new instance of the class.
12 | ///
13 | public FusionCacheSerializationException()
14 | {
15 | }
16 |
17 | /// Initializes a new instance of the class with a specified error message.
18 | /// The message that describes the error.
19 | public FusionCacheSerializationException(string? message)
20 | : base(message)
21 | {
22 | }
23 |
24 | /// Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception.
25 | /// The error message that explains the reason for the exception.
26 | /// The exception that is the cause of the current exception. If the innerException parameter is not a null reference (Nothing in Visual Basic), the current exception is raised in a catch block that handles the inner exception.
27 | public FusionCacheSerializationException(string? message, Exception? innerException)
28 | : base(message, innerException)
29 | {
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache/GlobalAttributes.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.CompilerServices;
2 |
3 | [assembly: InternalsVisibleTo("ZiggyCreatures.FusionCache.Benchmarks")]
4 | [assembly: InternalsVisibleTo("ZiggyCreatures.FusionCache.Tests")]
5 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache/GlobalSuppressions.cs:
--------------------------------------------------------------------------------
1 | // This file is used by Code Analysis to maintain SuppressMessage
2 | // attributes that are applied to this project.
3 | // Project-level suppressions either have no target or are given
4 | // a specific target and scoped to a namespace, type, member, etc.
5 |
6 | using System.Diagnostics.CodeAnalysis;
7 |
8 | [assembly: SuppressMessage("Performance", "HAA0101:Array allocation for params parameter")]
9 | [assembly: SuppressMessage("Performance", "HAA0302:Display class allocation to capture closure")]
10 | [assembly: SuppressMessage("Performance", "HAA0301:Closure Allocation Source")]
11 | //[assembly: SuppressMessage("Performance", "HAA0303:Lambda or anonymous method in a generic method allocates a delegate instance")]
12 | //[assembly: SuppressMessage("Performance", "HAA0601:Value type to reference type conversion causing boxing allocation")]
13 | [assembly: SuppressMessage("Simplification", "RCS1049:Simplify boolean comparison.")]
14 | [assembly: SuppressMessage("Style", "IDE0090:Use 'new(...)'")]
15 | [assembly: SuppressMessage("Style", "IDE0290:Use primary constructor")]
16 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache/IFusionCacheProvider.cs:
--------------------------------------------------------------------------------
1 | namespace ZiggyCreatures.Caching.Fusion;
2 |
3 | ///
4 | /// The provider to work with multiple named FusionCache instances, kinda like Microsoft's HTTP named clients (see https://learn.microsoft.com/en-us/aspnet/core/fundamentals/http-requests#named-clients)
5 | ///
6 | public interface IFusionCacheProvider
7 | {
8 | ///
9 | /// Returns the FusionCache instance with the corresponding name.
10 | ///
11 | /// The name of the cache: it must match the one provided during registration.
12 | /// The FusionCache instance corresponding to the cache name specified.
13 | IFusionCache GetCache(string cacheName);
14 |
15 | ///
16 | /// Returns the FusionCache instance with the corresponding name, or if none found.
17 | ///
18 | /// The name of the cache: it must match the one provided during registration.
19 | /// The FusionCache instance corresponding to the cache name specified.
20 | IFusionCache? GetCacheOrNull(string cacheName);
21 | }
22 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache/Internals/AutoRecovery/AutoRecoveryItem.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 |
3 | namespace ZiggyCreatures.Caching.Fusion.Internals.AutoRecovery;
4 |
5 | [DebuggerDisplay("{" + nameof(Action) + "} ON {" + nameof(CacheKey) + "} AT {" + nameof(Timestamp) + "} (EXP: {" + nameof(ExpirationTicks) + "} RET: {" + nameof(RetryCount) + "})")]
6 | internal sealed class AutoRecoveryItem
7 | {
8 | public AutoRecoveryItem(string cacheKey, FusionCacheAction action, long timestamp, FusionCacheEntryOptions options, long expirationTicks, int? maxRetryCount)
9 | {
10 | CacheKey = cacheKey;
11 | Action = action;
12 | Timestamp = timestamp;
13 | Options = options ?? throw new ArgumentNullException(nameof(options));
14 | ExpirationTicks = expirationTicks;
15 | RetryCount = maxRetryCount;
16 | }
17 |
18 | public string CacheKey { get; }
19 | public FusionCacheAction Action { get; }
20 | public long Timestamp { get; }
21 | public FusionCacheEntryOptions Options { get; }
22 | public long ExpirationTicks { get; }
23 | public int? RetryCount { get; private set; }
24 |
25 | public bool IsExpired()
26 | {
27 | return ExpirationTicks <= DateTimeOffset.UtcNow.Ticks;
28 | }
29 |
30 | public void RecordRetry()
31 | {
32 | if (RetryCount is not null)
33 | RetryCount--;
34 | }
35 |
36 | public bool CanRetry()
37 | {
38 | if (RetryCount is null)
39 | return true;
40 |
41 | return RetryCount.Value > 0;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache/Internals/Diagnostics/CacheLevelKind.cs:
--------------------------------------------------------------------------------
1 | namespace ZiggyCreatures.Caching.Fusion.Internals.Diagnostics;
2 |
3 | internal enum CacheLevelKind
4 | {
5 | Memory = 0,
6 | Distributed = 1
7 | }
8 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache/Internals/Diagnostics/Tags.cs:
--------------------------------------------------------------------------------
1 | namespace ZiggyCreatures.Caching.Fusion.Internals.Diagnostics;
2 |
3 | internal static class Tags
4 | {
5 | internal static class Names
6 | {
7 | public const string CacheName = "fusioncache.cache.name";
8 | public const string CacheInstanceId = "fusioncache.cache.instance_id";
9 |
10 | public const string OperationKey = "fusioncache.operation.key";
11 | public const string OperationId = "fusioncache.operation.operation_id";
12 | public const string OperationTag = "fusioncache.operation.tag";
13 | public const string OperationLevel = "fusioncache.operation.level";
14 | public const string OperationBackground = "fusioncache.operation.background";
15 |
16 | public const string Hit = "fusioncache.hit";
17 | public const string Stale = "fusioncache.stale";
18 |
19 | public const string FactoryEagerRefresh = "fusioncache.factory.eager_refresh";
20 |
21 |
22 | public const string MemoryEvictReason = "fusioncache.memory.evict_reason";
23 |
24 | public const string DistributedCircuitBreakerClosed = "fusioncache.distributed.circuit_breaker.closed";
25 |
26 | public const string BackplaneCircuitBreakerClosed = "fusioncache.backplane.circuit_breaker.closed";
27 | public const string BackplaneMessageAction = "fusioncache.backplane.message_action";
28 | public const string BackplaneMessageSourceId = "fusioncache.backplane.message_source_id";
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache/Internals/FusionCacheAction.cs:
--------------------------------------------------------------------------------
1 | namespace ZiggyCreatures.Caching.Fusion.Internals;
2 |
3 | internal enum FusionCacheAction
4 | {
5 | Unknown = 0,
6 | EntrySet = 1,
7 | EntryRemove = 2,
8 | EntryExpire = 3
9 | }
10 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache/Internals/ImmutableTypeCache.cs:
--------------------------------------------------------------------------------
1 | namespace ZiggyCreatures.Caching.Fusion.Internals;
2 |
3 | // SOURCE: https://github.com/dotnet/extensions/blob/main/src/Libraries/Microsoft.Extensions.Caching.Hybrid/Internal/ImmutableTypeCache.T.cs
4 | // COPIED (ALMOST) AS-IS FOR MAXIMUM COMPATIBILITY WITH HybridCache
5 | internal static class ImmutableTypeCache // lazy memoize; T doesn't change per cache instance
6 | {
7 | // note for blittable types: a pure struct will be a full copy every time - nothing shared to mutate
8 | public static readonly bool IsImmutable = /*(typeof(T).IsValueType && ImmutableTypeCache.IsBlittable()) ||*/ FusionCacheInternalUtils.IsTypeImmutable(typeof(T));
9 | }
10 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache/Internals/Memory/IFusionCacheMemoryEntry.cs:
--------------------------------------------------------------------------------
1 | using ZiggyCreatures.Caching.Fusion.Internals.Distributed;
2 | using ZiggyCreatures.Caching.Fusion.Serialization;
3 |
4 | namespace ZiggyCreatures.Caching.Fusion.Internals.Memory;
5 |
6 | ///
7 | /// Represents a memory entry in , but as a non-generic interface so it can be used from code that doesn't know the actual type of the value (eg: auto-recovery and other places).
8 | ///
9 | internal interface IFusionCacheMemoryEntry
10 | : IFusionCacheEntry
11 | {
12 | object? Value { get; }
13 |
14 | byte[] GetSerializedValue(IFusionCacheSerializer serializer);
15 |
16 | (bool error, bool isSame, bool hasUpdated) TryUpdateMemoryEntryFromDistributedEntry(string operationId, string cacheKey, FusionCache cache);
17 | ValueTask<(bool error, bool isSame, bool hasUpdated)> TryUpdateMemoryEntryFromDistributedEntryAsync(string operationId, string cacheKey, FusionCache cache);
18 |
19 | ValueTask SetDistributedEntryAsync(string operationId, string key, DistributedCacheAccessor dca, FusionCacheEntryOptions options, bool isBackground, CancellationToken token);
20 | }
21 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache/Internals/Provider/LazyNamedCache.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 |
3 | namespace ZiggyCreatures.Caching.Fusion.Internals.Provider;
4 |
5 | [DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")]
6 | internal sealed class LazyNamedCache : IDisposable
7 | {
8 | private string GetDebuggerDisplay()
9 | {
10 | return $"CACHE: {CacheName} - INSTANTIATED: {_cache is not null}";
11 | }
12 |
13 | public LazyNamedCache(string name, Func cacheFactory)
14 | {
15 | if (name is null)
16 | throw new ArgumentNullException(nameof(name));
17 |
18 | if (cacheFactory is null)
19 | throw new ArgumentNullException(nameof(cacheFactory));
20 |
21 | CacheName = name;
22 | _cacheFactory = cacheFactory;
23 | }
24 |
25 | public LazyNamedCache(string name, IFusionCache cache)
26 | {
27 | if (name is null)
28 | throw new ArgumentNullException(nameof(name));
29 |
30 | if (cache is null)
31 | throw new ArgumentNullException(nameof(cache));
32 |
33 | CacheName = name;
34 | _cache = cache;
35 | }
36 |
37 | private readonly object _mutex = new();
38 | private IFusionCache? _cache;
39 | private readonly Func? _cacheFactory;
40 |
41 | public string CacheName { get; }
42 |
43 | public IFusionCache Cache
44 | {
45 | get
46 | {
47 | if (_cache is not null)
48 | return _cache;
49 |
50 | lock (_mutex)
51 | {
52 | if (_cache is not null)
53 | return _cache;
54 |
55 | if (_cacheFactory is null)
56 | throw new InvalidOperationException("No cache and no cache factory specified: this should not be possible.");
57 |
58 | return _cache = _cacheFactory();
59 | }
60 | }
61 | }
62 |
63 | public void Dispose()
64 | {
65 | _cache?.Dispose();
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache/NullObjects/NullBackplane.cs:
--------------------------------------------------------------------------------
1 | using ZiggyCreatures.Caching.Fusion.Backplane;
2 |
3 | namespace ZiggyCreatures.Caching.Fusion.NullObjects;
4 |
5 | ///
6 | /// An implementation of that implements the null object pattern, meaning that it does nothing. Consider this a kind of a pass-through implementation.
7 | ///
8 | public class NullBackplane
9 | : IFusionCacheBackplane
10 | {
11 | ///
12 | public void Subscribe(BackplaneSubscriptionOptions options)
13 | {
14 | // EMPTY
15 | }
16 |
17 | ///
18 | public ValueTask SubscribeAsync(BackplaneSubscriptionOptions options)
19 | {
20 | return new ValueTask();
21 | }
22 |
23 | ///
24 | public void Unsubscribe()
25 | {
26 | // EMPTY
27 | }
28 |
29 | ///
30 | public ValueTask UnsubscribeAsync()
31 | {
32 | return new ValueTask();
33 | }
34 |
35 | ///
36 | public void Publish(BackplaneMessage message, FusionCacheEntryOptions options, CancellationToken token = default)
37 | {
38 | // EMPTY
39 | }
40 |
41 | ///
42 | public ValueTask PublishAsync(BackplaneMessage message, FusionCacheEntryOptions options, CancellationToken token = default)
43 | {
44 | return new ValueTask();
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache/NullObjects/NullDistributedCache.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Extensions.Caching.Distributed;
2 |
3 | namespace ZiggyCreatures.Caching.Fusion.NullObjects;
4 |
5 | ///
6 | /// An implementation of that implements the null object pattern, meaning that it does nothing. Consider this a kind of a pass-through implementation.
7 | ///
8 | public class NullDistributedCache
9 | : IDistributedCache
10 | {
11 | ///
12 | public byte[]? Get(string key)
13 | {
14 | return null!;
15 | }
16 |
17 | ///
18 | public Task GetAsync(string key, CancellationToken token = default)
19 | {
20 | return Task.FromResult(null!);
21 | }
22 |
23 | ///
24 | public void Refresh(string key)
25 | {
26 | // EMPTY
27 | }
28 |
29 | ///
30 | public Task RefreshAsync(string key, CancellationToken token = default)
31 | {
32 | return Task.CompletedTask;
33 | }
34 |
35 | ///
36 | public void Remove(string key)
37 | {
38 | // EMPTY
39 | }
40 |
41 | ///
42 | public Task RemoveAsync(string key, CancellationToken token = default)
43 | {
44 | return Task.CompletedTask;
45 | }
46 |
47 | ///
48 | public void Set(string key, byte[] value, DistributedCacheEntryOptions options)
49 | {
50 | // EMPTY
51 | }
52 |
53 | ///
54 | public Task SetAsync(string key, byte[] value, DistributedCacheEntryOptions options, CancellationToken token = default)
55 | {
56 | return Task.CompletedTask;
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/ZiggyCreatures.FusionCache/NullObjects/NullMemoryLocker.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Extensions.Logging;
2 | using ZiggyCreatures.Caching.Fusion.Locking;
3 |
4 | namespace ZiggyCreatures.Caching.Fusion.NullObjects;
5 |
6 | ///
7 | /// An implementation of that implements the null object pattern, meaning that it does nothing. Consider this a kind of a pass-through implementation.
8 | ///
9 | public class NullMemoryLocker
10 | : IFusionCacheMemoryLocker
11 | {
12 | ///
13 | public object? AcquireLock(string cacheName, string cacheInstanceId, string operationId, string key, TimeSpan timeout, ILogger? logger, CancellationToken token)
14 | {
15 | return null;
16 | }
17 |
18 | ///
19 | public ValueTask