Skip to content

Commit

Permalink
Merge pull request #263 from dotnetcore/dev
Browse files Browse the repository at this point in the history
v1.1.0
  • Loading branch information
catcherwong authored Nov 21, 2020
2 parents 9914b86 + db73e8f commit 68dd48a
Show file tree
Hide file tree
Showing 48 changed files with 1,387 additions and 560 deletions.
7 changes: 7 additions & 0 deletions EasyCaching.sln
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "bus", "bus", "{B337509B-75F
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyCaching.LiteDB", "src\EasyCaching.LiteDB\EasyCaching.LiteDB.csproj", "{BA850294-3103-4540-8A27-FC768E1DC8FC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyCaching.Serialization.SystemTextJson", "serialization\EasyCaching.Serialization.SystemTextJson\EasyCaching.Serialization.SystemTextJson.csproj", "{4FCF16BF-5E21-4B74-AB45-3C121ADF1485}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -178,6 +180,10 @@ Global
{BA850294-3103-4540-8A27-FC768E1DC8FC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BA850294-3103-4540-8A27-FC768E1DC8FC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BA850294-3103-4540-8A27-FC768E1DC8FC}.Release|Any CPU.Build.0 = Release|Any CPU
{4FCF16BF-5E21-4B74-AB45-3C121ADF1485}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4FCF16BF-5E21-4B74-AB45-3C121ADF1485}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4FCF16BF-5E21-4B74-AB45-3C121ADF1485}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4FCF16BF-5E21-4B74-AB45-3C121ADF1485}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -209,6 +215,7 @@ Global
{43AD80E9-696B-4042-9D50-B26F48BE1928} = {A0F5CC7E-155F-4726-8DEB-E966950B3FE9}
{711603E1-8363-4F8D-9AA9-8C03EC8BD35F} = {B4241D34-A973-4A13-BD89-9BAE3F2BDDF6}
{BA850294-3103-4540-8A27-FC768E1DC8FC} = {A0F5CC7E-155F-4726-8DEB-E966950B3FE9}
{4FCF16BF-5E21-4B74-AB45-3C121ADF1485} = {15070C49-A507-4844-BCFE-D319CFBC9A63}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {63A57886-054B-476C-AAE1-8D7C8917682E}
Expand Down
13 changes: 8 additions & 5 deletions build/releasenotes.props
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project>
<PropertyGroup>
<EasyCachingCorePackageNotes>
1. IRedisProvider support search keys.
2. DefaultEasyCachingKeyGenerator support GenerateCacheKeyForModel.
1. Allow to cache null value.
2. Ready for 1.x version.
</EasyCachingCorePackageNotes>
<EasyCachingMemcachedPackageNotes>
1. Upgrading dependencies.
</EasyCachingMemcachedPackageNotes>
<EasyCachingRedisPackageNotes>
1. IRedisProvider support search keys.
1. Upgrading dependencies.
</EasyCachingRedisPackageNotes>
<EasyCachingSQLitePackageNotes>
1. Upgrading dependencies.
Expand Down Expand Up @@ -38,7 +38,7 @@
1. Upgrading dependencies.
</EasyCachingProtobufPackageNotes>
<EasyCachingCSRedisPackageNotes>
1. IRedisProvider support search keys.
1. Upgrading dependencies.
</EasyCachingCSRedisPackageNotes>
<EasyCachingCSRedisBusPackageNotes>
1. Upgrading dependencies.
Expand All @@ -53,7 +53,10 @@
1. Upgrading dependencies.
</EasyCachingDiskPackageNotes>
<EasyCachingLiteDBPackageNotes>
1. LiteDB joined for the first time.
1. Upgrading dependencies.
</EasyCachingLiteDBPackageNotes>
<EasyCachingSTJsonPackageNotes>
1. Init.
</EasyCachingSTJsonPackageNotes>
</PropertyGroup>
</Project>
39 changes: 20 additions & 19 deletions build/version.props
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
<Project>
<PropertyGroup>
<EasyCachingCorePackageVersion>0.9.0</EasyCachingCorePackageVersion>
<EasyCachingMemcachedPackageVersion>0.9.0</EasyCachingMemcachedPackageVersion>
<EasyCachingRedisPackageVersion>0.9.0</EasyCachingRedisPackageVersion>
<EasyCachingSQLitePackageVersion>0.9.0</EasyCachingSQLitePackageVersion>
<EasyCachingInMemoryPackageVersion>0.9.0</EasyCachingInMemoryPackageVersion>
<EasyCachingHybridPackageVersion>0.9.0</EasyCachingHybridPackageVersion>
<EasyCachingAspectCorePackageVersion>0.9.0</EasyCachingAspectCorePackageVersion>
<EasyCachingCastlePackageVersion>0.9.0</EasyCachingCastlePackageVersion>
<EasyCachingResponseCachingPackageVersion>0.9.0</EasyCachingResponseCachingPackageVersion>
<EasyCachingJsonPackageVersion>0.9.0</EasyCachingJsonPackageVersion>
<EasyCachingMessagePackPackageVersion>0.9.0</EasyCachingMessagePackPackageVersion>
<EasyCachingProtobufPackageVersion>0.9.0</EasyCachingProtobufPackageVersion>
<EasyCachingCSRedisPackageVersion>0.9.0</EasyCachingCSRedisPackageVersion>
<EasyCachingRedisBusPackageVersion>0.9.0</EasyCachingRedisBusPackageVersion>
<EasyCachingCSRedisBusPackageVersion>0.9.0</EasyCachingCSRedisBusPackageVersion>
<EasyCachingRabbitBusPackageVersion>0.9.0</EasyCachingRabbitBusPackageVersion>
<EasyCachingDiskPackageVersion>0.9.0</EasyCachingDiskPackageVersion>
<EasyCachingMsExtPackageVersion>0.9.0</EasyCachingMsExtPackageVersion>
<EasyCachingLiteDBPackageVersion>0.9.0</EasyCachingLiteDBPackageVersion>
<EasyCachingCorePackageVersion>1.1.0</EasyCachingCorePackageVersion>
<EasyCachingMemcachedPackageVersion>1.1.0</EasyCachingMemcachedPackageVersion>
<EasyCachingRedisPackageVersion>1.1.0</EasyCachingRedisPackageVersion>
<EasyCachingSQLitePackageVersion>1.1.0</EasyCachingSQLitePackageVersion>
<EasyCachingInMemoryPackageVersion>1.1.0</EasyCachingInMemoryPackageVersion>
<EasyCachingHybridPackageVersion>1.1.0</EasyCachingHybridPackageVersion>
<EasyCachingAspectCorePackageVersion>1.1.0</EasyCachingAspectCorePackageVersion>
<EasyCachingCastlePackageVersion>1.1.0</EasyCachingCastlePackageVersion>
<EasyCachingResponseCachingPackageVersion>1.1.0</EasyCachingResponseCachingPackageVersion>
<EasyCachingJsonPackageVersion>1.1.0</EasyCachingJsonPackageVersion>
<EasyCachingMessagePackPackageVersion>1.1.0</EasyCachingMessagePackPackageVersion>
<EasyCachingProtobufPackageVersion>1.1.0</EasyCachingProtobufPackageVersion>
<EasyCachingCSRedisPackageVersion>1.1.0</EasyCachingCSRedisPackageVersion>
<EasyCachingRedisBusPackageVersion>1.1.0</EasyCachingRedisBusPackageVersion>
<EasyCachingCSRedisBusPackageVersion>1.1.0</EasyCachingCSRedisBusPackageVersion>
<EasyCachingRabbitBusPackageVersion>1.1.0</EasyCachingRabbitBusPackageVersion>
<EasyCachingDiskPackageVersion>1.1.0</EasyCachingDiskPackageVersion>
<EasyCachingMsExtPackageVersion>1.1.0</EasyCachingMsExtPackageVersion>
<EasyCachingLiteDBPackageVersion>1.1.0</EasyCachingLiteDBPackageVersion>
<EasyCachingSTJsonPackageVersion>1.1.0</EasyCachingSTJsonPackageVersion>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public string Aspectcore(int type = 1)
var res = _aService.GetDemo(111);
return $"{res.Id}-{res.Name}-{res.CreateTime}";
}
else if (type == 5)
{
var res = _aService.GetData();
return Newtonsoft.Json.JsonConvert.SerializeObject(res);
}
else
{
return "wait";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public interface IAspectCoreService //: EasyCaching.Core.Internal.IEasyCaching

[EasyCachingAble(Expiration = 10)]
Demo GetDemo(int id);

[EasyCachingAble(Expiration = 10)]
object GetData();
}

public class AspectCoreService : IAspectCoreService
Expand Down Expand Up @@ -71,6 +74,10 @@ public string PutSomething(string str)
return str;
}

public object GetData()
{
return new { x = System.DateTimeOffset.Now.ToUnixTimeSeconds() };
}
}

[ProtoContract]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
using System;
using System.Collections.Generic;
using System.Text.Encodings.Web;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace EasyCaching.Serialization.SystemTextJson.Configurations
{
public class EasyCachingJsonSerializerOptions
{
/// <summary>
/// Gets or sets the encoder to use when escaping strings, or null to use the default
/// encoder.
/// </summary>
public JavaScriptEncoder Encoder => JavaScriptEncoder.UnsafeRelaxedJsonEscaping;
/// <summary>
/// Gets or sets a value that defines how comments are handled during deserialization.
/// </summary>
public JsonCommentHandling ReadCommentHandling => JsonCommentHandling.Disallow;
/// <summary>
/// Gets or sets a value that specifies the policy used to convert a property's name
/// on an object to another format, such as camel-casing, or null to leave property
/// names unchanged.
/// </summary>
public JsonNamingPolicy PropertyNamingPolicy => null;
/// <summary>
/// Gets or sets a value that determines whether a property's name uses a case-insensitive
/// comparison during deserialization. The default value is false.
/// </summary>
public bool PropertyNameCaseInsensitive => false;
/// <summary>
/// Specifies how number types should be handled when serializing or deserializing.
/// </summary>
public JsonNumberHandling NumberHandling => JsonNumberHandling.Strict;
/// <summary>
/// Gets or sets the maximum depth allowed when serializing or deserializing JSON,
/// with the default value of 0 indicating a maximum depth of 64.
/// </summary>
public int MaxDepth => 0;
/// <summary>
/// Determines whether fields are handled serialization and deserialization. The
/// default value is false.
/// </summary>
public bool IncludeFields => false;
/// <summary>
/// Gets a value that determines whether read-only properties are ignored during
/// serialization. The default value is false.
/// </summary>
public bool IgnoreReadOnlyProperties => false;
/// <summary>
/// Determines whether read-only fields are ignored during serialization. A property
/// is read-only if it isn't marked with the readonly keyword. The default value is false.
/// </summary>
public bool IgnoreReadOnlyFields => false;
/// <summary>
/// Gets or sets a value that determines whether null values are ignored during serialization
/// and deserialization. The default value is false.
/// </summary>
public bool IgnoreNullValues = false;
/// <summary>
/// Gets or sets the policy used to convert a System.Collections.IDictionary key's
/// name to another format, such as camel-casing.
/// </summary>
public JsonNamingPolicy DictionaryKeyPolicy => null;
/// <summary>
/// Specifies a condition to determine when properties with default values are ignored
/// during serialization or deserialization. The default value is System.Text.Json.Serialization.JsonIgnoreCondition.Never.
/// </summary>
public JsonIgnoreCondition DefaultIgnoreCondition => JsonIgnoreCondition.Never;
/// <summary>
/// Gets or sets the default buffer size, in bytes, to use when creating temporary buffers.
/// </summary>
public int DefaultBufferSize => 16 * 1024;
/// <summary>
/// Gets the list of user-defined converters that were registered.
/// </summary>
public IList<JsonConverter> Converters => new List<JsonConverter>();
/// <summary>
/// Get or sets a value that indicates whether an extra comma at the end of a list
/// of JSON values in an object or array is allowed (and ignored) within the JSON
/// payload being deserialized.
/// </summary>
public bool AllowTrailingCommas => false;
/// <summary>
/// Configures how object references are handled when reading and writing JSON.
/// </summary>
public ReferenceHandler ReferenceHandler => null;
/// <summary>
/// Gets or sets a value that defines whether JSON should use pretty printing. By
/// default, JSON is serialized without any extra white space.
/// </summary>
public bool WriteIndented => false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using EasyCaching.Core.Configurations;
using System;
using System.Linq;
using System.Text.Json;

namespace EasyCaching.Serialization.SystemTextJson.Configurations
{

/// <summary>
/// EasyCaching options extensions.
/// </summary>
public static class EasyCachingOptionsExtensions
{
/// <summary>
/// Withs the json serializer.
/// </summary>
/// <param name="options">Options.</param>
/// <param name="name">The name of this serializer instance.</param>
public static EasyCachingOptions WithSystemTextJson(this EasyCachingOptions options, string name = "json") => options.WithSystemTextJson(configure: x => { }, name);

/// <summary>
/// Withs the json serializer.
/// </summary>
/// <param name="options">Options.</param>
/// <param name="configure">Configure serializer settings.</param>
/// <param name="name">The name of this serializer instance.</param>
public static EasyCachingOptions WithSystemTextJson(this EasyCachingOptions options, Action<EasyCachingJsonSerializerOptions> configure, string name)
{
var easyCachingJsonSerializerOptions = new EasyCachingJsonSerializerOptions();

configure(easyCachingJsonSerializerOptions);

void jsonSerializerSettings(JsonSerializerOptions x)
{
x.MaxDepth = easyCachingJsonSerializerOptions.MaxDepth;
x.AllowTrailingCommas = easyCachingJsonSerializerOptions.AllowTrailingCommas;
x.Converters.Union(easyCachingJsonSerializerOptions.Converters);
x.DefaultBufferSize = easyCachingJsonSerializerOptions.DefaultBufferSize;
x.DefaultIgnoreCondition = easyCachingJsonSerializerOptions.DefaultIgnoreCondition;
x.DictionaryKeyPolicy = easyCachingJsonSerializerOptions.DictionaryKeyPolicy;
x.Encoder = easyCachingJsonSerializerOptions.Encoder;
x.IgnoreReadOnlyFields = easyCachingJsonSerializerOptions.IgnoreReadOnlyFields;
x.IgnoreReadOnlyProperties = easyCachingJsonSerializerOptions.IgnoreReadOnlyProperties;
x.IncludeFields = easyCachingJsonSerializerOptions.IncludeFields;
x.NumberHandling = easyCachingJsonSerializerOptions.NumberHandling;
x.PropertyNameCaseInsensitive = easyCachingJsonSerializerOptions.PropertyNameCaseInsensitive;
x.PropertyNamingPolicy = easyCachingJsonSerializerOptions.PropertyNamingPolicy;
x.ReadCommentHandling = easyCachingJsonSerializerOptions.ReadCommentHandling;
x.ReferenceHandler = easyCachingJsonSerializerOptions.ReferenceHandler;
x.WriteIndented = easyCachingJsonSerializerOptions.WriteIndented;
}

options.RegisterExtension(new JsonOptionsExtension(name, jsonSerializerSettings));

return options;
}

/// <summary>
/// Withs the json serializer.
/// </summary>
/// <param name="options">Options.</param>
/// <param name="jsonSerializerSettingsConfigure">Configure serializer settings.</param>
/// <param name="name">The name of this serializer instance.</param>
public static EasyCachingOptions WithSystemTextJson(this EasyCachingOptions options, Action<JsonSerializerOptions> jsonSerializerSettingsConfigure, string name)
{
options.RegisterExtension(new JsonOptionsExtension(name, jsonSerializerSettingsConfigure));

return options;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using EasyCaching.Core.Configurations;
using EasyCaching.Core.Serialization;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Text.Json;

namespace EasyCaching.Serialization.SystemTextJson
{
/// <summary>
/// Json options extension.
/// </summary>
internal sealed class JsonOptionsExtension : IEasyCachingOptionsExtension
{
/// <summary>
/// The name.
/// </summary>
private readonly string _name;

/// <summary>
/// The configure.
/// </summary>
private readonly Action<JsonSerializerOptions> _configure;

/// <summary>
/// Initializes a new instance of the <see cref="T:EasyCaching.Serialization.SystemTextJson.JsonOptionsExtension"/> class.
/// </summary>
/// <param name="name">Name.</param>
/// <param name="configure">Configure.</param>
public JsonOptionsExtension(string name, Action<JsonSerializerOptions> configure)
{
_name = name;
_configure = configure;
}

public void AddServices(IServiceCollection services)
{
Action<JsonSerializerOptions> configure = x => { };

if (_configure != null) configure = _configure;

services.AddOptions();
services.Configure(_name, configure);
services.AddSingleton<IEasyCachingSerializer, DefaultJsonSerializer>(x =>
{
var optionsMon = x.GetRequiredService<Microsoft.Extensions.Options.IOptionsMonitor<JsonSerializerOptions>>();
var options = optionsMon.Get(_name);
return new DefaultJsonSerializer(_name, options);
});
}
}
}
Loading

0 comments on commit 68dd48a

Please sign in to comment.