无法从memcached取回缓存的项目? [英] Can't get cached items back from memcached?

查看:82
本文介绍了无法从memcached取回缓存的项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是在网络上的ubuntu系统上设置了memcached.没有更改任何选项,因此所有内容均为默认设置.我认为尝试使用Enyim连接到服务器.它不会失败,但是当我尝试检索项目时,它们始终为null.我不是很低级,但是在之前我已经能够从Wireshk辨别出什么,所以我决定尝试一下.我无法识别任何内容,但是我注意到我发送的第一个.Store()命令实际上将发送的网络数据包发送到了正确的地址.每个.Store()命令绝对不执行任何操作.

I just setup memcached on a ubuntu system i have on my network. Didn't change any options so everything is default. I think tried to connect to the server using Enyim. It doesn't fail but when i try to retrieve the items they are always null. I'm not much of a low level won't but i've been able to discern things from wireshark before so i decided to give it a try. I'haven't been able to discern anything but i noticed the first .Store() command i sent actually sent network packets to the correct address. Every .Store() command did absolutely nothing.

这是我的app.config:

Here is my app.config:

我尝试过二进制"和"文本"协议,他们做了同样的事情.

I've tried both "Binary" & "Text" Protocols and they did the same thing.

这是我的C#代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using Enyim.Caching;
using Enyim.Caching.Configuration;
using Enyim.Caching.Memcached;

namespace MemCacheTest
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            //var config = new MemcachedClientConfiguration();
            //config.Servers.Add(new IPEndPoint(new IPAddress(new byte[] {10, 0, 0, 1}), 11211));
            //config.Protocol = MemcachedProtocol.Binary;

            var mc = new MemcachedClient();
            for (var i = 0; i < 100; i++)
               mc.Store(StoreMode.Set, "Hello", "World");
            mc.Store(StoreMode.Set, "MyKey", "Hello World");
            Console.WriteLine(mc.Get("MyKey"));
            Console.WriteLine("It should have failed!!!");

            Console.ReadLine();

        }

    }
}

有人知道发生了什么事或如何确定出什么问题了吗?我以为没有得到任何例外很奇怪,所以我在配置文件中设置了无效的IP地址.结果相同.

Does anyone know whats going on or how i could determine what is wrong? I thought it was strange that i wasn't getting any exceptions so i set an invalid ip address in the config file. Same results.

推荐答案

简短的答案:如果您的服务正在运行,请检查您的端口,应该以某种方式阻止它. (您是否在Ubuntu防火墙(iptables)中添加了端口11211的例外?)

The short answer: If your service is running check your port, it should be blocked somehow. (did you add an exception for port 11211 in Ubuntu firewall(iptables)?)

telnet 10.0.0.1 11211如果服务器上有telnet客户端,这将显示该端口不可访问.

telnet 10.0.0.1 11211 If you have a telnet client on your server this will show the port is inaccessible.

即使端口不可访问,Enyim也不会向您抛出错误.是的,很奇怪.

Enyim doesn't throw you an error even the port is inaccessible. yes, it's strange.

这篇关于无法从memcached取回缓存的项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆