namespace Test { class Program { static void Main(string[] args) { DistCache.Add("mytest","123456",100000); Console.WriteLine(DistCache.Get<string>("mytest")); Console.ReadLine(); } } }
配置文件
<?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="cacheProvider" type="MemcachedProviders.Cache.CacheProviderSection, MemcachedProviders" allowDefinition="MachineToApplication" restartOnExternalChanges="true"/> <sectionGroup name="enyim.com"> <section name="memcached" type="Enyim.Caching.Configuration.MemcachedClientSection, Enyim.Caching" /> </sectionGroup> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/> </configSections> <enyim.com> <memcached> <servers> <!-- put your own server(s) here--> <!--<add address="192.168.0.252" port="11222" />--> <add address="127.0.0.1" port="11211" /> </servers> <socketPool minPoolSize="10" maxPoolSize="100" connectionTimeout="00:00:10" deadTimeout="00:02:00" /> </memcached> </enyim.com> <cacheProvider defaultProvider="MemcachedCacheProvider"> <providers> <add name="MemcachedCacheProvider" type="MemcachedProviders.Cache.MemcachedCacheProvider, MemcachedProviders" keySuffix="" defaultExpireTime="2000"/> </providers> </cacheProvider> <log4net> <!-- Define some output appenders --> <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender"> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" /> </layout> </appender> <!--<threshold value="OFF" />--> <!-- Setup the root category, add the appenders and set the default priority --> <root> <priority value="WARN"/> <appender-ref ref="ConsoleAppender"> <filter type="log4net.Filter.LevelRangeFilter"> <levelMin value="WARN"/> <levelMax value="FATAL"/> </filter> </appender-ref> </root> </log4net> </configuration>
在Add后Get前加入断点可以通过telnet,输入命令stats cachedump 1 0中看到
但是gets时取不到
搞了一下午了不知道问题出在哪?我把过期时间设置很大也不行
我现在遇到的问题是 add时 两个缓存,一个是string类型的,一个是List<>类型的.
然后 string类型的可以获取到,但List类型的获取为null.
我擦 同样的问题啊 兄弟有没有解决呢