Coder Social home page Coder Social logo

dotnetcore / easycaching Goto Github PK

View Code? Open in Web Editor NEW
1.9K 76.0 316.0 3.58 MB

:boom: EasyCaching is an open source caching library that contains basic usages and some advanced usages of caching which can help us to handle caching more easier!

License: MIT License

C# 99.86% Batchfile 0.14%
caching memory-cache distributed-cache aspnetcore redis memcached sqlite hybrid-cache interceptor cache

easycaching's Introduction

EasyCaching is an open source caching library that contains basic usages and some advanced usages of caching which can help us to handle caching more easily!

Coverage Status Member project of .NET Core Community GitHub license FOSSA Status

CI Build Status

Platform Build Server Master Status Dev Status
Github Action Linux/Windows Build&Test Build&Test

Nuget Packages

Package Name Version Downloads
EasyCaching.Core
EasyCaching.InMemory
EasyCaching.Redis
EasyCaching.Memcached
EasyCaching.SQLite
EasyCaching.HybridCache
EasyCaching.CSRedis
EasyCaching.FreeRedis
EasyCaching.FasterKv
EasyCaching.Interceptor.Castle
EasyCaching.Interceptor.AspectCore
EasyCaching.Serialization.MessagePack
EasyCaching.Serialization.Json
EasyCaching.Serialization.Protobuf
EasyCaching.Bus.RabbitMQ
EasyCaching.Bus.RabbitMQStream
EasyCaching.Bus.Redis
EasyCaching.Bus.CSRedis
EasyCaching.Bus.ConfluentKafka
EasyCaching.Bus.Zookeeper
EasyCaching.ResponseCaching
EasyCaching.Disk
EasyCaching.LiteDB
EasyCaching.Serialization.SystemTextJson

Basic Usages

Step 1 : Install the package

Choose caching provider that you need and install it via Nuget.

Install-Package EasyCaching.InMemory
Install-Package EasyCaching.Redis
Install-Package EasyCaching.SQLite
Install-Package EasyCaching.Memcached
Install-Package EasyCaching.FasterKv

Step 2 : Configure Startup class

Each caching provider has it's own configuration options.

Here is a sample configuration for InMemory and Redis caching provider.

public class Startup
{
    //...
    
    public void ConfigureServices(IServiceCollection services)
    {
        //configuration
        services.AddEasyCaching(options => 
        {
            //use memory cache that named default
            options.UseInMemory("default");

            // // use memory cache with your own configuration
            // options.UseInMemory(config => 
            // {
            //     config.DBConfig = new InMemoryCachingOptions
            //     {
            //         // scan time, default value is 60s
            //         ExpirationScanFrequency = 60, 
            //         // total count of cache items, default value is 10000
            //         SizeLimit = 100 
            //     };
            //     // the max random second will be added to cache's expiration, default value is 120
            //     config.MaxRdSecond = 120;
            //     // whether enable logging, default is false
            //     config.EnableLogging = false;
            //     // mutex key's alive time(ms), default is 5000
            //     config.LockMs = 5000;
            //     // when mutex key alive, it will sleep some time, default is 300
            //     config.SleepMs = 300;
            // }, "m2");

            //use redis cache that named redis1
            options.UseRedis(config => 
            {
                config.DBConfig.Endpoints.Add(new ServerEndPoint("127.0.0.1", 6379));
            }, "redis1")
            .WithMessagePack()//with messagepack serialization
            ;            
        });    
    }    
}

Step 3 : Write code in your controller

[Route("api/[controller]")]
public class ValuesController : Controller
{
    // //when using single provider
    // private readonly IEasyCachingProvider _provider;
    //when using multiple provider
    private readonly IEasyCachingProviderFactory _factory;

    public ValuesController(
        //IEasyCachingProvider provider, 
        IEasyCachingProviderFactory factory
        )
    {
        //this._provider = provider;
        this._factory = factory;
    }

    [HttpGet]
    public string Handle()
    {
        //var provider = _provider;
        //get the provider from factory with its name
        var provider = _factory.GetCachingProvider("redis1");    

        //Set
        provider.Set("demo", "123", TimeSpan.FromMinutes(1));
            
        //Set Async
        await provider.SetAsync("demo", "123", TimeSpan.FromMinutes(1));                  
    }
}

Documentation

Detailed EasyCaching documentation can be found here.

Extension Libs

Examples

See sample

Todo List

See ToDo List

Contributing

Pull requests, issues and commentary!

License

FOSSA Status

easycaching's People

Contributors

alexinea avatar alphayu avatar amiru3f avatar billhong-just avatar bingtianyiyan avatar catcherwong avatar dependabot[bot] avatar fossabot avatar haiduong87 avatar huoshan12345 avatar incerrygit avatar labelzhou avatar maikebing avatar marklonquist avatar memoyu avatar mjebrahimi avatar moientajik avatar mokarchi avatar mtgervasoni avatar mzorec avatar pengweiqhca avatar rwing avatar sarmis avatar trackycn avatar victorioberra avatar vla avatar wech71 avatar wlclass avatar xsoheilalizadeh avatar yrinleung avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

easycaching's Issues

Make configurations more easier

Description

The configurations of EasyCaching is a little complex and dispersive. We should combine them with only one entry.

Steps to Reproduce

None

Related code

 public void ConfigureServices(IServiceCollection services)
 {
    services.AddEasyCaching(option =>
    {
        option.UseInMemory(xxx);
        option.UseRedis(xxx).WithMessagePack();
        //...
    });
}

//SQLite and Memcached
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
    app.UseEasyCaching();
}

Specifications

None

EasyCaching.Interceptor.AspectCore的用法对原有项目有代码侵入

image
现有实现,是对实现了IEasyCaching接口的类进行拦截,这样做对代码有侵入,一个老的项目能不动代码最好不动,如果通过匹配表达式来拦截就可以做到代码的零侵入,这么做的缺点是灵活性降低了,我推荐做法是优先通过匹配表达式拦截,如果有个别方法有特殊需求再用自定义属性来定义。

Redesign InMemory Caching Provider

Description

There are some concurrent problems when using TrySet/TrySetAsync.

Here is the current implementation.

if (_cache.TryGetValue(BuildCacheKey(Name, cacheKey), out var obj))
{
    return false;
}
else
{
    Set(cacheKey, cacheValue, expiration);
    return true;
}   

Here I will use ConcurrentDictionary<TKey,TValue> to implement a simple memory cache for InMemory caching provider.

Steps to Reproduce

Following the related code

Related code

[Fact]
public void Parallel_Test_Should_Be_Succeed()
{
    var key = "ParallelTest";
    var list = new List<bool>();
    Parallel.For(1,20,x=>
    { 
        list.Add(_provider.TrySet(key,1,TimeSpan.FromSeconds(1)));             
    });
    Assert.Equal(1,list.Count(c=>c));
}

Expected behavior: The test should always pass.

Actual behavior: Some of time, the test will not pass.

Specifications

  • Provider : InMemory (version 0.4.5)
  • Interceptor : not use
  • Serializer : not use

下载源码,运行EasyCaching.Demo.Interceptors示例,返回Task的方法缓存处理异常

Description

SerializationException: Type 'System.Threading.Tasks.Task`1[[System.String, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]' in Assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' is not marked as serializable.
System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(Type type)

AspectInvocationException: Exception has been thrown by the aspect of an invocation. ---> Type 'System.Threading.Tasks.Task`1[[System.String, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]' in Assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' is not marked as serializable..
AspectCore.DynamicProxy.AspectActivator.InvokeTask(AspectActivatorContext activatorContext)

 if (!string.IsNullOrWhiteSpace(cacheKey) && context.ReturnValue != null)
                        await CacheProvider.SetAsync(cacheKey, context.ReturnValue, TimeSpan.FromSeconds(attribute.Expiration));
  • Provider : Redis (version 0.3.0)
  • Interceptor : AspectCore (version 0.2.0)
  • Serializer : not use
  • System : Win10

Does it support the Task<T>?

    [EasyCachingAble (Expiration = 100)]
    Task<PremiseTrans> GetPremise (int id);

    [EasyCachingAble (Expiration = 100)]
    Task<PremiseTrans> GetPremise (string letter);

    [EasyCachingAble (Expiration = 100)]
    Task<IEnumerable<PremiseSimple>> GetPremises (string search, string sort, string order);

    [EasyCachingAble (Expiration = 1000)]
    Task<IEnumerable<PremiseTrans>> GetPremises (string search, string area, string price, string houseType, string special, string type, string sort, string order, string query, int limit = 10, int pageIndex = 1, int skip = 0);

    [EasyCachingAble (Expiration = 1000, CacheKeyPrefix = "Premise")]
    Task<long> GetCountAsync (string search, string area, string price, string houseType, string special, string type, string sort, string order, string query);

value is unreadable in any redis manager

I tried Redis Desktop Manager 0.9.3 & 0.8.8, Redis Client, Aonther Redis DeskTop Manager,Redis-cli etc.
Any manager I can find, all tried.
It will show the value like this
�������� System.Int32��m_value���!�
or this
\x00\x01\x00\x00\x00\xff\xff\xff\xff\x01\x00\x00\x00\x00\x00\x00\x00\x04\x01\x00\x00\x00\x0cSystem.Int32\x01\x00\x00\x00\am_value\x00\b\b\xe9!\x00\x0b
or nothing in plaintText.
I also tied JSON,XML,HEX. All value is unreadable. It's hard to maintenance.

Redis Verson: 3.2.100

请教一下缓存问题

一个比较菜的问题,如果缓存未过期,这时候是否需要先删除缓存,再set,还是直接可以set?

Do you support reading IP and port from appsettings.config file?

Description

[Description of the bug or feature]

Steps to Reproduce

Related code

insert short code snippets here

Expected behavior: [What you expected to happen]

Actual behavior: [What actually happened]

Specifications

  • Provider : InMemory (version 0.2.0)
  • Interceptor : AspectCore (version 0.2.0)
  • Serializer : not use
  • System : CentOS 7.2

Redis中AOP切面的拦截器如何实现泛型

AOP切面的拦截器中,第一次把List序列化成字符串,或者数组存到Redis中,然后在有效期内,下一次访问的时候,把存下来的字符串或者数组通过反序列化成相应的泛型list 或者 实体类,,如何在AOP使用泛型

不是core项目能使用吗,怎么注册?谢谢

Description

不是core项目能使用吗,怎么注册?谢谢

Steps to Reproduce

Related code

insert short code snippets here

Expected behavior: [What you expected to happen]

Actual behavior: [What actually happened]

Specifications

  • Provider : InMemory (version 0.2.0)
  • Interceptor : AspectCore (version 0.2.0)
  • Serializer : not use
  • System : CentOS 7.2

i get a problem in my code

image

it's my code to update redis
image

this activity has some property
image

but second to insertOrUpdate Datetime? will change value 。
I'm sure I got the value is right from foreground ,
but update reids or get from redis has some problem

HybridCache调用出现异常

描述

我根据官方文档在samples中的EasyCaching.Demo.Providers中使用HybridCache,出现了一些问题是否是我初始化错误了?

初始化信息:

services.AddEasyCaching(option=> 
            {
                //use memory cache
                option.UseInMemory("default");

                //use redis cache
                option.UseRedis(config => 
                {
                    config.DBConfig.Endpoints.Add(new ServerEndPoint("127.0.0.1", 6379));
                }, "redis1")
                ;
                // combine local and distributed
                option.UseHybrid(config =>
                {
                    config.TopicName = "test-topic";
                    config.EnableLogging = false;

                    config.LocalCacheProviderName = "default";
                    config.DistributedCacheProviderName = "redis1";
                })
                    .WithRabbitMQBus(x=>
                    {
                        x.HostName = "127.0.0.1";
                        x.UserName = "admin";
                        x.Password = "admin";
                    });
            });

堆栈信息:

System.InvalidOperationException: Unable to resolve service for type 'EasyCaching.HybridCache.HybridCachingOptions' while attempting to activate 'EasyCaching.HybridCache.HybridCachingProvider'.
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(Type serviceType, Type implementationType, CallSiteChain callSiteChain, ParameterInfo[] parameters, Boolean throwIfCallSiteNotFound)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite(Type serviceType, Type implementationType, CallSiteChain callSiteChain)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(ServiceDescriptor descriptor, Type serviceType, CallSiteChain callSiteChain)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(Type serviceType, CallSiteChain callSiteChain)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateCallSite(Type serviceType, CallSiteChain callSiteChain)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.CreateServiceAccessor(Type serviceType)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetService(IServiceProvider sp, Type type, Type requiredBy, Boolean isDefaultParameterRequired)
   at lambda_method(Closure , IServiceProvider , Object[] )
   at Microsoft.AspNetCore.Mvc.Controllers.ControllerActivatorProvider.<>c__DisplayClass4_0.<CreateActivator>b__0(ControllerContext controllerContext)
   at Microsoft.AspNetCore.Mvc.Controllers.ControllerFactoryProvider.<>c__DisplayClass5_0.<CreateControllerFactory>g__CreateController|0(ControllerContext controllerContext)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
   at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

JSON serialization

Description

Configurable JSON serializer

Steps to Reproduce

It would be good if the JSON serializer could be configured with some options. For example I need to ignore self referencing loops for one of my types. This is easily done with an option on the NewtonSoft JsonSerializer but cant use this functionality in the EasyCaching wrapper.

Thanks

Related code

new JsonSerializer { ReferenceLoopHandling = ReferenceLoopHandling.Ignore };

Specifications

  • Provider : MemCached (version 0.2.0)
  • Interceptor : AspectCore (version 0.2.0)
  • Serializer : not use
  • System : CentOS 7.2

Some questions when using EasyCachingEvictAttribute to remove cached item.

public interface IAspectCoreService : EasyCaching.Core.Internal.IEasyCaching
    {
        [EasyCachingAble(Expiration = 10)]
        string GetCurrentUtcTime();

        [EasyCachingPut(CacheKeyPrefix = "AspectCore")]
        string PutSomething(string str);

        [EasyCachingEvict(IsBefore = true)]
        void DeleteSomething(int id);

        [EasyCachingAble(Expiration = 10)]
        Task<string> GetUtcTimeAsync();
    }

我看你这边是获取方法名的,那么 我在DeleteSomething这个方法里面要触发 移除 PutSomething 这个缓存的信息,那么这里会有个问题,是无法移除的

Add Remove by prefix method in caching providers.

Most of time , our cache keys will be formatted by some customizable rules .

Some samples are as follow :

[ModuleName]:[SubModuleName]:[IDs]
[ProjectName]:[ClassName]:[MethodName]:[Params]
....

Also we need to remove the cached item via their prefix , for example , if we want to remove all of the cached item start with [ModuleName]:[SubModuleName]: due to some reasons.

This function will be used in some special scenarios .

I open this issue mainly for discussing .

time out error

Description

when i use _provider.GetAsync method and set expiration is TimeSpan.FromSeconds(2) i not doing well,after 2 seconds it will not time out , it cost long time to timeout

Related code

services.AddEasyCaching(option =>
            {
                //use memory cache that named default
                option.UseInMemory("default");
            });
var res = await _provider.GetAsync(cacheKey,
                                async () => await some mehod, TimeSpan.FromSeconds(2));

Expected behavior: [What you expected to happen]

Actual behavior: [What actually happened]

Specifications

  • Provider : InMemory (version 0.5.4)
  • Interceptor : AspectCore (version 2.2)
  • Serializer : not use
  • System : windows

Castle的拦截器为什么用的Autofac

目前用的Abp的框架,想配置拦截器。由于没找到Castle.Windsor的注入点。只有Autofac的。所以请教一下。如何使用Castle.Windsor进行拦截。

        return services.AddAbp<QrCodeWarehouseWebApiModule>(o =>
        {
            o.IocManager.IocContainer.AddAspectCoreFacility().Register(
                Component.For<EasyCachingInterceptor>().LifestyleTransient(),
                Component.For<MethodExecuteLoggerInterceptor>().LifestyleTransient());
        });

进程间缓存无法获取

在使用inmemory模式时,当我在a.cs里面缓存的数据,无法在b.cs里面获取,这是为啥?

Who is using EasyCaching

First of all, thanks sincerely for your interest in this project. We will try our best to keep EasyCaching better and keep growing the community. To attract more people to use and contribute to EasyCaching, please comment on this issue to include the following information:

  • Your company, school or organization.
  • Your city and country.
  • Your contact info: blog, email, twitter.
  • For what scenario do you use EasyCaching.

首先诚挚地感谢每一位对 EasyCaching 感兴趣的朋友。我们会持续投入,争取把 EasyCaching 变得更好,把社区变得更加繁荣。为了更好的聆听社区的声音,吸引更多的人使用和参与,我们期待您在此提交一条评论, 评论内容包括:

  • 您所在公司、学校或组织
  • 您所在的城市、国家
  • 您的联系方式: 博客、邮箱、微博
  • 您将 EasyCaching 用于哪些业务场景

增加绝对过期和过期方案

Description

[Description of the bug or feature]

Steps to Reproduce

  1. 缓存数据增加统一包装 增加字段 【过期时间】 用于存储缓存过期时间
  2. 命中缓存时 核对【过期时间】如果时间超过则执行更新委托。

Related code

insert short code snippets here

Expected behavior: [What you expected to happen]

Actual behavior: [What actually happened]

Specifications

  • Provider : InMemory (version 0.2.0)
  • Interceptor : AspectCore (version 0.2.0)
  • Serializer : not use
  • System : CentOS 7.2

Support Sliding Expiration Feature?

It's useful model for extend the expiration automatically sometime.
I haven't found related infomation about this feature.
Would you consider to support this feature?

How to use the hashset or the hashget in easycaching.redis

Description

[Description of the bug or feature]

Steps to Reproduce

Related code

insert short code snippets here

Expected behavior: [What you expected to happen]

Actual behavior: [What actually happened]

Specifications

  • Provider : InMemory (version 0.2.0)
  • Interceptor : AspectCore (version 0.2.0)
  • Serializer : not use
  • System : CentOS 7.2

SQLite Get ExpiresAt is {1/1/0001 12:00:00 AM +00:00}

Description

image

Steps to Reproduce

  1. SetAsync
  2. Refresh
  3. GetAsync

Expected behavior: [What you expected to happen]
An expiration > 1/1/0001

Actual behavior: [What actually happened]
expiration == 1/1/0001

Specifications

  • Provider : SQLite (version 0.5.3)

用get方法取值時發生stackoverflowexception

Description

[Description of the bug or feature]

Steps to Reproduce

  1. 用get方法取值時發生stackoverflowexception

Related code

provider.Get()

Expected behavior: [What you expected to happen]

Debug模式運行網站前期會先把setting values 到memory,
接著運行中斷,發生exception
請問有可能什麼原因?

Specifications

  • Provider : InMemory 0.5.4
  • Interceptor : AspectCore (version 0.2.0)
  • Serializer : not use
  • System : win10

Add TrySet method for providers

Description

We need TrySet/TrySetAsync methods for providers.

If we want to add a cache with an existed key, we should not handle it and return false.

If the cache is not an existed key, we should add it to the cached value and return true.

Steps to Reproduce

None

Related code

bool TrySet<T>(string cacheKey, T cacheValue, TimeSpan expiration);

Task<bool> TrySetAsync<T>(string cacheKey, T cacheValue, TimeSpan expiration);

Specifications

None

Adding mutex key for Get/GetAsync method

Description

We need to add mutex key for Get/GetAsync with data retriever that prevents to many request visit the data retriever at a time.

Steps to Reproduce

None.

Related code

if(get mutext key == true)
{
    visit the data retriever method
}
else
{
    1. sleep for a short time
    2. redo the get method
}

Specifications

None

I try Autofac Property Injection, but failed

I am using Autofac IOC. But haven't found related document about how work with Autofac.
Found DefaultCSRedisCachingProvider in your code repo after search.

When I try
builder.RegisterType().As();

It failed.

Trace: AsyncMethodBuilderCore.Start => d__7.MoveNext => DiagnosticsLoggerExtensions.UnhandledException
Message: An unhandled exception has occurred while executing the request.
Exception: Autofac.Core.DependencyResolutionException: An exception was thrown while activating EasyCaching.CSRedis.DefaultCSRedisCachingProvider. ---> Autofac.Core.DependencyResolutionException: None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'EasyCaching.CSRedis.DefaultCSRedisCachingProvider' can be invoked with the available services and parameters:
Cannot resolve parameter 'System.String name' of constructor 'Void .ctor(System.String, System.Collections.Generic.IEnumerable1[EasyCaching.CSRedis.EasyCachingCSRedisClient], EasyCaching.Core.Serialization.IEasyCachingSerializer, EasyCaching.CSRedis.RedisOptions, Microsoft.Extensions.Logging.ILoggerFactory)'. at Autofac.Core.Activators.Reflection.ReflectionActivator.GetValidConstructorBindings(IComponentContext context, IEnumerable1 parameters) in C:\projects\autofac\src\Autofac\Core\Activators\Reflection\ReflectionActivator.cs:line 160
at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable1 parameters) in C:\projects\autofac\src\Autofac\Core\Activators\Reflection\ReflectionActivator.cs:line 120 at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 parameters, Object& decoratorTarget) in C:\projects\autofac\src\Autofac\Core\Resolving\InstanceLookup.cs:line 118
--- End of inner exception stack trace ---
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 parameters, Object& decoratorTarget) in C:\projects\autofac\src\Autofac\Core\Resolving\InstanceLookup.cs:line 136 at Autofac.Core.Resolving.InstanceLookup.Execute() in C:\projects\autofac\src\Autofac\Core\Resolving\InstanceLookup.cs:line 85 at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable1 parameters) in C:\projects\autofac\src\Autofac\Core\Resolving\ResolveOperation.cs:line 130
at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable1 parameters, Object& instance) in C:\projects\autofac\src\Autofac\ResolutionExtensions.cs:line 1041 at Autofac.Core.Activators.Reflection.AutowiringPropertyInjector.InjectProperties(IComponentContext context, Object instance, IPropertySelector propertySelector, IEnumerable1 parameters) in C:\projects\autofac\src\Autofac\Core\Activators\Reflection\AutowiringPropertyInjector.cs:line 105
at Autofac.Core.Registration.ComponentRegistration.RaiseActivating(IComponentContext context, IEnumerable1 parameters, Object& instance) in C:\projects\autofac\src\Autofac\Core\Registration\ComponentRegistration.cs:line 186 at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 parameters, Object& decoratorTarget) in C:\projects\autofac\src\Autofac\Core\Resolving\InstanceLookup.cs:line 151
at Autofac.Core.Resolving.InstanceLookup.Execute() in C:\projects\autofac\src\Autofac\Core\Resolving\InstanceLookup.cs:line 85
at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable1 parameters) in C:\projects\autofac\src\Autofac\Core\Resolving\ResolveOperation.cs:line 130 at Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable1 parameters) in C:\projects\autofac\src\Autofac\Core\Resolving\ResolveOperation.cs:line 83
at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable1 parameters, Object& instance) in C:\projects\autofac\src\Autofac\ResolutionExtensions.cs:line 1041 at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable1 parameters) in C:\projects\autofac\src\Autofac\ResolutionExtensions.cs:line 871
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at Microsoft.AspNetCore.Mvc.Controllers.ServiceBasedControllerActivator.Create(ControllerContext actionContext)
at Microsoft.AspNetCore.Mvc.Controllers.ControllerFactoryProvider.<>c__DisplayClass5_0.g__CreateController|0(ControllerContext controllerContext)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

关于缓存AOP

我现在用的DI是Autofac,但是再使用AOP时候,好像无效。return
services.ConfigureAspectCoreInterceptor(options => options.CacheProviderName = EasyCachingConstValue.DefaultInMemoryName) Bulid了,这样就不得行,希望大佬指正一下可以增门使用.顺便再问一句AOP目前只支持InMemory吗?

EasyCaching能否同时支持多种缓存方式?

例如现在AddDefaultRedisCache,那IEasyCachingProvider就是应该就是RedisCacheProvider,但我在代码里面有地方想用InMemoryCache,这个能实现吗?还有就是同时想用多个Redis库,根据一个key来决定用哪个,这个能实现吗?

Can we set cache without expiration?

我在使用redis时候set值的必须要设置一个过期时间,但是我在实际中,这个值是不需要过期的,没有找到其它的方法

Support Named Caching Provider

Description

We need named providers that we can use different types or one type with multi instances at a project. This will be similar with HttpClientFactory.

Origin #54

Steps to Reproduce

None

Related code

private readonly IEasyCachingProviderFactory _factory;

public ValuesController(IEasyCachingProviderFactory factory)
{
    this._factory = factory;
}

[HttpGet]
public string Get(string name)
{
    var provider = _factory.GetCachingProvider(name);
    var val = $"{name}-{Guid.NewGuid()}";
    var res = provider.Get("named-provider", () => val, TimeSpan.FromMinutes(1));
    return $"cached value : {res}";
}

Specifications

None

NOAUTH Authentication required

Description

运行大概 2040分钟 突然
Running for about 20
40 minutes, suddenly

StackExchange.Redis.RedisServerException: 'NOAUTH Authentication required.'
image

Steps to Reproduce

  1. 突然中断 缓存清空
  2. 平时正常

Related code

_provider.Get<List<Spideing>>("list").IsNull

Expected behavior: 12

Actual behavior: 1212

Specifications

12

  • System : win10 docker

ETA on DIsk Caching?

I need disk caching for a simple desktop app. It has some OAuth tokens I need to save through app crashes and whatnot. All the other caching options are overkill. Any thoughts?

Object must implement IConvertible..

Description

using EasyCachingAbleAttribute,it throws an exception: Object must implement IConvertible.

Related code

 [EasyCachingAble(CacheKeyPrefix = "prefix")]
 Task<IEnumerable<CountModuleViewModel>> GetModules();

Specifications

  • Provider : Redis (version 0.2.0)
  • Interceptor : AspectCore (version 0.2.0)
  • Serializer : not use
  • System : Windows 64

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.