Skip to content

Commit 6b4aa73

Browse files
authored
Merge pull request #264 from haiduong87/patch-1
Update DefaultSQLiteCachingProvider.cs
2 parents db73e8f + 53b9916 commit 6b4aa73

File tree

8 files changed

+50
-5
lines changed

8 files changed

+50
-5
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ EasyCaching is an open source caching library that contains basic usages and som
3636
| EasyCaching.ResponseCaching | ![](https://img.shields.io/nuget/v/EasyCaching.ResponseCaching.svg) | ![](https://img.shields.io/nuget/dt/EasyCaching.ResponseCaching.svg)
3737
| EasyCaching.Disk | ![](https://img.shields.io/nuget/v/EasyCaching.Disk.svg) | ![](https://img.shields.io/nuget/dt/EasyCaching.Disk.svg)
3838
| EasyCaching.LiteDB | ![](https://img.shields.io/nuget/v/EasyCaching.LiteDB.svg) | ![](https://img.shields.io/nuget/dt/EasyCaching.LiteDB.svg)
39+
| EasyCaching.Serialization.SystemTextJson | ![](https://img.shields.io/nuget/v/EasyCaching.Serialization.SystemTextJson.svg) | ![](https://img.shields.io/nuget/dt/EasyCaching.Serialization.SystemTextJson.svg)
3940

4041
## Basic Usages
4142

@@ -153,7 +154,7 @@ See [sample](https://github.com/catcherwong/EasyCaching/tree/master/sample)
153154

154155
## Todo List
155156

156-
See [ToDo List](ToDoList.md)
157+
See [ToDo List](docs/ToDoList.md)
157158

158159
## Contributing
159160

docs/Features.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@
3232
2. MessagePack
3333
3. Json
3434
4. Protobuf
35+
5. System.Text.Json
3536
- ResponseCaching for ASP.NET Core
File renamed without changes.

docs/SystemTextJson.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# DefaultJsonSerializer
2+
3+
DefaultJsonSerializer is a serializer based on **System.Text.Json**.
4+
5+
# How to Use?
6+
7+
## Install the package via Nuget
8+
9+
```
10+
Install-Package EasyCaching.Serialization.SystemTextJson
11+
```
12+
13+
## Configuration
14+
15+
```
16+
public class Startup
17+
{
18+
//others...
19+
20+
public void ConfigureServices(IServiceCollection services)
21+
{
22+
services.AddMvc();
23+
24+
services.AddEasyCaching(options =>
25+
{
26+
// with a default name [json]
27+
options.WithSystemTextJson();
28+
29+
// with a custom name [myname]
30+
options.WithSystemTextJson("myname");
31+
32+
// add some serialization settings
33+
Action<EasyCachingJsonSerializerOptions> easycaching = x =>
34+
{
35+
36+
};
37+
options.WithSystemTextJson(easycaching, "easycaching_setting");
38+
});
39+
}
40+
}
41+
```

docs/ToDoList.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
- [x] MessagePack
3737
- [x] Json
3838
- [x] ProtoBuf
39+
- [x] System.Text.Json
3940
- [ ] Others...
4041

4142
## Caching Interceptor

docs/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ EasyCaching is an open source caching library that contains basic usages and som
2828
| EasyCaching.Bus.CSRedis | ![](https://img.shields.io/nuget/v/EasyCaching.Bus.CSRedis.svg) | ![](https://img.shields.io/nuget/dt/EasyCaching.Bus.CSRedis.svg)
2929
| EasyCaching.ResponseCaching | ![](https://img.shields.io/nuget/v/EasyCaching.ResponseCaching.svg) | ![](https://img.shields.io/nuget/dt/EasyCaching.ResponseCaching.svg)
3030
| EasyCaching.Disk | ![](https://img.shields.io/nuget/v/EasyCaching.Disk.svg) | ![](https://img.shields.io/nuget/dt/EasyCaching.Disk.svg)
31-
| EasyCaching.LiteDB | ![](https://img.shields.io/nuget/v/EasyCaching.LiteDB.svg) | ![](https://img.shields.io/nuget/dt/EasyCaching.LiteDB.svg)
31+
| EasyCaching.LiteDB | ![](https://img.shields.io/nuget/v/EasyCaching.LiteDB.svg) | ![](https://img.shields.io/nuget/dt/EasyCaching.LiteDB.svg)
32+
| EasyCaching.Serialization.SystemTextJson | ![](https://img.shields.io/nuget/v/EasyCaching.Serialization.SystemTextJson.svg) | ![](https://img.shields.io/nuget/dt/EasyCaching.Serialization.SystemTextJson.svg)

mkdocs.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ pages:
2828
- Overview : SerializerOverview.md
2929
- BinaryFormatter : BinaryFormatter.md
3030
- MessagePack : MessagePack.md
31-
- Json : Json.md
31+
- NewtonsoftJson : NewtonsoftJson.md
32+
- SystemTextJson : SystemTextJson.md
3233
- Protobuf : ProtoBuf.md
3334

src/EasyCaching.SQLite/DefaultSQLiteCachingProvider.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public partial class DefaultSQLiteCachingProvider : EasyCachingAbstractProvider
3131
/// <summary>
3232
/// The cache.
3333
/// </summary>
34-
private readonly SqliteConnection _cache;
34+
private SqliteConnection _cache => _dbProvider.GetConnection();
3535

3636
/// <summary>
3737
/// The cache stats.
@@ -54,7 +54,6 @@ public DefaultSQLiteCachingProvider(
5454
this._dbProvider = dbProviders.Single(x => x.DBProviderName.Equals(name));
5555
this._options = options;
5656
this._logger = loggerFactory?.CreateLogger<DefaultSQLiteCachingProvider>();
57-
this._cache = _dbProvider.GetConnection();
5857
this._cacheStats = new CacheStats();
5958
this._name = name;
6059

0 commit comments

Comments
 (0)