Solved

PHP >> Memcache >> C#

Posted on 2014-03-24
5
337 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 74

Accepted Solution

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

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now