首页 新闻 搜索 专区 学院

Memcached中通过MemcachedProviders客户端写入值并设置过期时间,读取为空?

0
悬赏园豆:20 [已关闭问题] 关闭于 2014-11-24 17:34
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时取不到

搞了一下午了不知道问题出在哪?我把过期时间设置很大也不行

lhn152391的主页 lhn152391 | 菜鸟二级 | 园豆:202
提问于:2014-11-24 16:48
< >
分享
所有回答(2)
0

我现在遇到的问题是 add时 两个缓存,一个是string类型的,一个是List<>类型的.

然后 string类型的可以获取到,但List类型的获取为null.

草根豆 | 园豆:204 (菜鸟二级) | 2015-04-18 18:45
0

我擦 同样的问题啊  兄弟有没有解决呢

gnahziak | 园豆:202 (菜鸟二级) | 2017-02-10 10:43
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册