?
Solved

PHP >> Memcache >> C#

Posted on 2014-03-24
5
Medium Priority
?
386 Views
Last Modified: 2014-03-24
Hi all,

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

<?php
$memcache = new Memcache;
$memcache->connect("localhost",11211);
$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.
0
Comment
Question by:meetsys
  • 2
  • 2
5 Comments
 
LVL 5

Expert Comment

by:jayakrishnabh
ID: 39950054
Please try this once..

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

Author Comment

by:meetsys
ID: 39950077
Hi,

I dont have a MemoryCache class to utilise so cannot use that.
0
 
LVL 5

Expert Comment

by:jayakrishnabh
ID: 39950108
If using >=.net 4.0 , add System.Runtime.Caching dll to use that class
0
 

Author Comment

by:meetsys
ID: 39950115
.net 2.0/3.5 and cant be changed.
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 2000 total points
ID: 39950487
Why are you "getting" a string array (line 3)? Shouldn't this simply be a string?
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Make the most of your online learning experience.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The viewer will learn how to dynamically set the form action using jQuery.
Introduction to Processes
Suggested Courses
Course of the Month13 days, 17 hours left to enroll

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question