Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MemoryPacker and Redis #443

Open
c5racing opened this issue Jan 6, 2023 · 5 comments
Open

MemoryPacker and Redis #443

c5racing opened this issue Jan 6, 2023 · 5 comments

Comments

@c5racing
Copy link

c5racing commented Jan 6, 2023

Description

I'm trying to replace the Newtonsoft Serializer with the new MemoryPacker to compare performance. When adding MemoryPacker, with Redis, I get an error any time trying to DI the EasyCachingLibraries

Steps to Reproduce

Register EasyCaching;
Attempt to resolve IEasyCachingProviderFactory;

Related code

            services.AddEasyCaching(options =>
            {
                options.UseRedis(config =>
                {
                    config.DBConfig.AllowAdmin = true;
                    config.DBConfig.Endpoints.Add(new EasyCaching.Core.Configurations.ServerEndPoint(redisSettings.Host, redisSettings.Port));
                    config.SerializerName = "mempack";
                    config.DBConfig.ConnectionTimeout = 10000;
                    config.EnableLogging = false;

                    if (!string.IsNullOrWhiteSpace(redisSettings.Password))
                    {
                        config.DBConfig.Password = redisSettings.Password;
                        config.DBConfig.IsSsl = true;
                    }
                }, cacheName).WithMemoryPack(x =>
                {
                    x.StringEncoding = StringEncoding.Utf8;
                }, "mempack");
            });

var providerFactory = serviceProvider.GetRequiredService<IEasyCachingProviderFactory>();

Expected behavior: [What you expected to happen]
I would expect to replace Newtonsoft with MessagePack

Actual behavior: [What actually happened]
Receive the following error when trying to resolve IEasyCachingProviderFactory

Autofac.Core.DependencyResolutionException
HResult=0x80131500
Message=An exception was thrown while activating λ:EasyCaching.Core.IRedisCachingProvider -> λ:EasyCaching.Core.Serialization.IEasyCachingSerializer[] -> λ:EasyCaching.Core.Serialization.IEasyCachingSerializer.
Source=Autofac
StackTrace:
at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.Middleware.RegistrationPipelineInvokeMiddleware.Execute(ResolveRequestContext context, Action1 next)
at Autofac.Core.Resolving.Middleware.SharingMiddleware.<>c__DisplayClass5_0.b__0()
at Autofac.Core.Lifetime.LifetimeScope.CreateSharedInstance(Guid id, Func1 creator) at Autofac.Core.Lifetime.LifetimeScope.CreateSharedInstance(Guid primaryId, Nullable1 qualifyingId, Func1 creator) at Autofac.Core.Resolving.Middleware.SharingMiddleware.Execute(ResolveRequestContext context, Action1 next)
at Autofac.Core.Resolving.Middleware.CircularDependencyDetectorMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.ResolveOperation.InvokePipeline(ResolveRequest request, DefaultResolveRequestContext requestContext) at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, ResolveRequest request) at Autofac.Core.Resolving.ResolveOperation.ExecuteOperation(ResolveRequest request) at Autofac.Core.Resolving.ResolveOperation.Execute(ResolveRequest request) at Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(ResolveRequest request) at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable1 parameters, Object& instance)
at Autofac.ResolutionExtensions.ResolveOptionalService(IComponentContext context, Service service, IEnumerable1 parameters) at Autofac.ResolutionExtensions.ResolveOptional(IComponentContext context, Type serviceType, IEnumerable1 parameters)
at Autofac.ResolutionExtensions.ResolveOptional(IComponentContext context, Type serviceType)
at Autofac.Extensions.DependencyInjection.AutofacServiceProvider.GetService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)
at Caching.CachingProvider..ctor(IOptions1 cacheSettings, IServiceProvider serviceProvider, ILockProvider lockProvider, ILogger1 logger) in C:\Users\admin\source\repos\SRM\src\BuildingBlocks\Caching\CachingProvider.cs:line 42
at Autofac.Core.Activators.Reflection.BoundConstructor.Instantiate()

This exception was originally thrown at this call stack:
[External Code]

Inner Exception 1:
MissingMethodException: Method not found: 'Void MemoryPack.MemoryPackSerializerOptions.set_StringEncoding(MemoryPack.StringEncoding)'.

@catcherwong
Copy link
Member

@c5racing Thanks for your interest in this project.

We will take a look ASAP.

@amiru3f Do you have time to take a look on this issue about MemoryPacker.

@dpetlyuk
Copy link

I have same the problem.
MissingMethodException: Method not found: 'Void MemoryPack.MemoryPackSerializerOptions.set_StringEncoding(MemoryPack.StringEncoding)'.

@c5racing
Copy link
Author

Any updates on this @amiru3f or @catcherwong?

@catcherwong
Copy link
Member

@c5racing Could you provide a sample for this issue? I cannot reproduce it.

@amiru3f
Copy link
Contributor

amiru3f commented Jul 12, 2023

Hey guys
Sorry for late response, I was away from my Github account for a long time.
Do you still have the problem? I can take a look.

@c5racing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants