forked from fluentcms/FluentCMS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor cache provider and remove AutoMapper dependency (fluentcms#2138
) * Refactor cache provider and remove AutoMapper dependency Added XML documentation to `ICacheProvider` for better clarity. Removed `AutoMapper` package reference from the project file. Refactored `InMemoryCacheProvider` to eliminate `AutoMapper` usage. Updated `TryGetValue` method to use `string` keys consistently. Simplified `InMemoryCacheProvider` to handle cached values directly. * Make repository methods virtual for easier overriding Updated EntityRepository methods (Create, CreateMany, Delete, DeleteMany, GetAll, GetByIds) and SiteAssociatedRepository's GetAllForSite to be virtual. Modified GetAllForSite to call GetAll directly.
- Loading branch information
1 parent
6e72d68
commit 9df88e7
Showing
6 changed files
with
50 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 27 additions & 1 deletion
28
...roviders/CacheProviders/FluentCMS.Providers.CacheProviders.Abstractions/ICacheProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,34 @@ | ||
namespace FluentCMS.Providers.CacheProviders; | ||
|
||
/// <summary> | ||
/// Interface for a cache provider that supports adding, retrieving, and removing cached items. | ||
/// </summary> | ||
public interface ICacheProvider | ||
{ | ||
/// <summary> | ||
/// Removes a specific item from the cache by its key. | ||
/// </summary> | ||
/// <param name="key">The unique string identifier for the cache entry.</param> | ||
void Remove(string key); | ||
|
||
/// <summary> | ||
/// Adds or updates an item in the cache. | ||
/// </summary> | ||
/// <typeparam name="T">The type of the value to cache.</typeparam> | ||
/// <param name="key">The unique string identifier for the cache entry.</param> | ||
/// <param name="value">The value to cache, of type <typeparamref name="T"/>.</param> | ||
void Set<T>(string key, T value); | ||
bool TryGetValue<T>(object key, out T? value); | ||
|
||
/// <summary> | ||
/// Attempts to retrieve a cached item by its key. | ||
/// </summary> | ||
/// <typeparam name="T">The type of the cached item.</typeparam> | ||
/// <param name="key">The unique string identifier for the cache entry.</param> | ||
/// <param name="value"> | ||
/// When this method returns, contains the cached item of type <typeparamref name="T"/> if found; otherwise, the default value for the type of the <paramref name="value"/> parameter. | ||
/// </param> | ||
/// <returns> | ||
/// <c>true</c> if the cache contains an item with the specified key; otherwise, <c>false</c>. | ||
/// </returns> | ||
bool TryGetValue<T>(string key, out T? value); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 14 additions & 15 deletions
29
src/Providers/CacheProviders/FluentCMS.Providers.CacheProviders/InMemoryCacheProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters