Memcached initialization errors

Hi I’m trying to use the Memcached system as explained in the documentation:

container.Register<IDbConnectionFactory>(new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider));

            container.Register<ICacheClient>(new MemcachedClientCache("127.0.0.0[:11211]"));

            var db = container.Resolve<IDbConnectionFactory>().Open();

I’ve got two errors:

Error    2    Argument 1: cannot convert from 'string' to 'Enyim.Caching.Configuration.IMemcachedClientConfiguration' 

Error	1	The best overloaded method match for 'ServiceStack.Caching.Memcached.MemcachedClientCache.MemcachedClientCache(Enyim.Caching.Configuration.IMemcachedClientConfiguration)' has some invalid arguments

If I pass no parameters to MemcachedClientCache I’ve got an exception error on application startup… “the value can’t be null” :-/
Anyone know what’s happening?

Thank you!

This is a compile error saying there is no constructor that accepts just a string, try instead:

var cache = new MemcachedClientCache(new[] { "127.0.0.0" });

Note the MemcachedClientCache is a wrapper around EnyimMemcached which is very infrequently maintained, but you can find additional details about how to configure it in your Web.config at their website.

Generally in-case you have a reason to use memcached I would use the more feature-rich, actively developed and maintained Redis server instead.

Thank you very much mythz I’ve tried the other cache solutions (except Redis that I will test soon) but the only one that seems to work is the In-Memory cache… the OrmLite cache seems to have a limit that does return only small amount of data (I’ve tried with a 10mb table and it doesn’t return nothing, it seems stuck).
Anyway… do you think Redis performances are better than In-Memory cache?
I’d just need a cache system to speed up my rest service based on MS SQL db… Have you a tutorial about it?

Nothing is going to beat an InMemory Cache which maintains the cache in the App Server memory, all other Caching providers are distributed. Redis is very fast, see the project page for info about using the C# Redis Client whilst there’s ample documentation about Redis server on the redis.io website.