PHP >> Memcache >> C#

Hi all,

I have a simple string that I am creating and placing in Memcache using PHP. Is as follows...

$memcache = new Memcache;
$memcache->set('mykey', "hello");

Open in new window

I can then access the string using Telnet so I know it is in there. I do this by referencing the "mykey" identifier.

Then we come onto .NET. I am using Enyim as the widely used .api to gain access to the memcache.

So when I try to retrieve the "mykey" data stored in memcache I dont get anything back. So like this...

using (MemcachedClient writeClient = new MemcachedClient())
string[] myString = writeClient.Get<string[]>("mykey");

Open in new window

I am wondering if it is to do with the dattype string from both lanuages. Any advise would be greatly appreciated with this.

Thank you.
Who is Participating?
käµfm³d 👽Connect With a Mentor Commented:
Why are you "getting" a string array (line 3)? Shouldn't this simply be a string?
Please try this once..

MemoryCache memoryCache = MemoryCache.Default;
            String mystring = Convert.ToString(memoryCache.Get("mykey", null));
meetsysAuthor Commented:

I dont have a MemoryCache class to utilise so cannot use that.
If using > 4.0 , add System.Runtime.Caching dll to use that class
meetsysAuthor Commented:
.net 2.0/3.5 and cant be changed.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.