Skip to content

Commit fdc76a9

Browse files
committed
docs: add read me
1 parent 17a621a commit fdc76a9

3 files changed

Lines changed: 66 additions & 4 deletions

File tree

CacheManager.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
<RepositoryType>public</RepositoryType>
1717
<PackageTags>CacheManager</PackageTags>
1818
<PackageReleaseNotes>CacheManager</PackageReleaseNotes>
19-
<AssemblyVersion>1.0.1</AssemblyVersion>
20-
<FileVersion>1.0.1</FileVersion>
19+
<AssemblyVersion>1.0.2</AssemblyVersion>
20+
<FileVersion>1.0.2</FileVersion>
21+
<Version>1.0.2</Version>
2122
<SignAssembly>true</SignAssembly>
2223
<AssemblyOriginatorKeyFile>MHKarami97.snk</AssemblyOriginatorKeyFile>
2324
<PublicSign>true</PublicSign>
@@ -26,7 +27,6 @@
2627
<ApplicationIcon>icon.ico</ApplicationIcon>
2728
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
2829
<IncludeContentInPack>true</IncludeContentInPack>
29-
<Version>1.0.1</Version>
3030
</PropertyGroup>
3131

3232
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">

CacheManagerIntegrationTest/EasyCacheManagerTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ public class EasyCacheManagerTests : IAsyncLifetime
1818
private SqlConnection _sqlConnection = null!;
1919
private EasyCacheManager<string> _easyCacheManager = null!;
2020

21-
2221
public async Task InitializeAsync()
2322
{
2423
// Set up SQL Server container

README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,64 @@
11
Manage Cache Easily
2+
3+
### Usage
4+
5+
First install package:
6+
7+
> https://www.nuget.org/packages/EasyMultiCacheManager
8+
9+
then you can use like this:
10+
11+
```csharp
12+
var easyCacheManager = new CacheBuilder<string>()
13+
.AddApi(new ApiConfig
14+
{
15+
Url = StaticData.Api
16+
})
17+
.AddRedis(new RedisConfig
18+
{
19+
ConnectionString = redisConnectionString
20+
})
21+
.AddDb(new DbConfig
22+
{
23+
ConnectionString = sqlConnectionString,
24+
Query = StaticData.QueryToSelect
25+
})
26+
.AddMemory(new MemoryConfig())
27+
.Build(new LockConfig());
28+
29+
var result = await easyCacheManager.GetAsync("My-Key");
30+
```
31+
You can create your own provider with these interfaces:
32+
33+
- IBaseCacheSource
34+
- ICacheSourceWithClear
35+
- ICacheSourceWithSet
36+
- ICacheSourceWithSetAndClear
37+
38+
Default providers are these:
39+
40+
- MemoryCacheSource : ICacheSourceWithSetAndClear : Priority => 1
41+
- RedisCacheSource : ICacheSourceWithSetAndClear : Priority => 2
42+
- DbCacheSource : IBaseCacheSource : Priority => 3
43+
- ApiCacheSource : IBaseCacheSource : Priority => 4
44+
45+
On `IBaseCacheSource` you have only `Get` from cache, for example on `ApiCacheSource` you get real data from api.
46+
if item find from one provider and not exist on other provider, it will automatically set to other providers that implemented from `ICacheSourceWithSetAndClear` or `ICacheSourceWithSet`
47+
48+
### Example
49+
First try get from Memory because it `Priority` is 1, if not exist it try get from redis, after that it try to get from db, and after that it get data from api. if not found it will return null.
50+
also if found on db or api it will set to redis and memory.
51+
52+
### Concurrency
53+
This package use AsyncKeyedLock to handle lock on get, set and clear on specific key. so you use this package on multi thread program.
54+
55+
### Info
56+
You can use all type like class, object, string to cache, for example EasyCacheManager<string>, EasyCacheManager<MyClass>
57+
Priority should be unique, you can't crate EasyCacheManager with list of providers with same Priority
58+
59+
### Clear cache
60+
With `ClearCacheAsync` method you can clear specific key on all providers that implement `ICacheSourceWithClear` or `ICacheSourceWithSetAndClear`
61+
62+
### Set
63+
With `SetAsync` you can manually set value to provides that that implement `ICacheSourceWithSet` or `ICacheSourceWithSetAndClear`
64+

0 commit comments

Comments
 (0)