Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8504477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:02:40+00:00 2026-06-11T02:02:40+00:00

I am trying to use memcached with both a php (memcached) and C# (enyim)

  • 0

I am trying to use memcached with both a php (memcached) and C# (enyim) client.
I have a scenario where I want to CAS a value in php. To do this I am using the following code:

$memcached = new Memcached;
$memcached->addServer('localhost', 11211) or die ("Could not connect");
$memcached->setOption(Memcached::OPT_COMPRESSION, false); // the enyim client doesn't support compression
do {
    $entries = $memcached->get($theKey, null, $cas);
    if ($memcached->getResultCode() == Memcached::RES_NOTFOUND) {
        $entry = somearray("foo");
        $memcached->add($theKey, $entry);
    } else {
        $entries[] = "bar";
        $memcached->cas($cas, $theKey, $entries);
    }
}
while ($memcached->getResultCode() != Memcached::RES_SUCCESS AND $memcached->getResultCode() != Memcached::RES_END);

This works all well and fine to begin with.
But then, when the C# client CAS’s the same value it goes wrong.
Php gives a warning at:

$entries = $memcached->get($theKey, null, $cas);

namely that:

 PHP Warning:  Memcached::get(): could not uncompress value in ... at line ...

And as a result an infinite loop occurs.

Now I tried to get the key from the memcached server via telnet and the data was right there.
In php I am also able to SET to this key without a problem.

I noticed one thing: after the php client has SET something, the flag was 0.
Now after the C# client has CAS’d the value, the flag was 274.
Is there some flag collision on the php lib going on? Or is it something else?

If anyone can help me resolve this problem I’d be gratefull!

lordstyx

[EDIT]

Well then. Since this question isn’t getting an answer let me put it differently.
Is there a way to stop the C# client from setting flag 274?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T02:02:41+00:00Added an answer on June 11, 2026 at 2:02 am

    So I eventually found an answer to my problem. It might not help all of you, because I switched from the Enyim to the BeIT memcached client (http://code.google.com/p/beitmemcached/)

    Now to make the BeIT client compatible with the php client you have to change Serializer.cs
    In the enum SerializedType I changed the number of “String” to 0 and ByteArray to 2, which gave this:

    internal enum SerializedType : ushort
    {
        ByteArray   = 2,
        Object      = 1,
        String      = 0, //mod: turned around the numbers for String and ByteArray so it is compatible with php client
        Datetime    = 3,
        ....
    

    I believe I went with BeIT because I couldn’t find or figure out how the flags worked in the Enyim client. If you understand how it work though, I’m sure that you can change that client in a same manner

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi All: Trying to use Memcached using BeIT.Memcached c# client. My config entry: <add
I'm trying use mod_rewrite to rewrite URLs from the following: http://www.site.com/one-two-file.php to http://www.site.com/one/two/file.php The
I'm trying to use Apache::Session::Memcached in an HTML::Mason project where I'm using MasonX::Request::WithApacheSession to
I'm trying to use http://www.flexablecoder.com/blog/index.cfm/memcached client. All works ok but for each cfm call,
I'm trying to use memcache to handle session in PHP. I still want to
I am trying use gem tire to search in my application. I have tables
Hi I'm trying use a datepicker on a field I have. I'm trying to
I am need paint my image. I'm trying use JQuery in here this link:
trying to use hibernate with my web app and getting following exception: Initial SessionFactory
I am trying to use sorl-thumbnail to provide image thumbnails. I have followed the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.