Giter Site home page Giter Site logo

Comments (11)

Tobion avatar Tobion commented on June 18, 2024

According to documentation, those return values cannot be returned from a simple get. So please provide a test case to prove something else.

from cache.

deeky666 avatar deeky666 commented on June 18, 2024

@Tobion unfortunately the docs are not revealing every implementation detail. There are even tests that cover those constants.

from cache.

Tobion avatar Tobion commented on June 18, 2024

I don't see a test for get and RES_NOTFOUND.

from cache.

riquito avatar riquito commented on June 18, 2024

I can't provide a test, but I suppose that if you try a get after shutting down memcached you won't get RES_NOTFOUND (can't try right now). At present I'm getting in a production server result code 47, MEMCACHED_SERVER_TEMPORARILY_DISABLED, which causes doContains() to return true (don't know how to reproduce it on purpose).

from cache.

deeky666 avatar deeky666 commented on June 18, 2024

@Tobion https://github.com/php-memcached-dev/php-memcached/blob/607860c656a3cea22fb164c4eb71d36ec869c598/tests/experimental/getmulti_partial_error.phpt#L23

from cache.

Tobion avatar Tobion commented on June 18, 2024

That is a multiget. I already said twice that this ticket is about a simple get returning those states. Please read more carefully. And for multiget it is also documented, see docs.

from cache.

riquito avatar riquito commented on June 18, 2024

Here are some links to the implementation of get in the php memcached extension.

return_code ranges from BAD_KEY_PROVIDED to RES_PAYLOAD_FAILURE to pretty much anything (see implementation of php_memc_handle_error)

from cache.

Tobion avatar Tobion commented on June 18, 2024

Does that work?

return false !== $this->memcached->get($id)
            || $this->memcached->getResultCode() !== Memcached::RES_SUCCESS;

from cache.

riquito avatar riquito commented on June 18, 2024

In libmemcached a result can be returned only if RES_SUCCESS is true, so it should be correct. I find the first part of the expression misleading because we don't care about the returned value and false is a legitimate result. I'd write it differently because it's easier to reason about, but maybe that's just me.

$this->memcached->get($id);
return $this->memcached->getResultCode() === Memcached::RES_SUCCESS;

edit: in your code you should compare Memcached::RES_SUCCESS for equality, not !==

from cache.

JonasHaouzi avatar JonasHaouzi commented on June 18, 2024

👍

We're faced to the same issue.

from cache.

Ocramius avatar Ocramius commented on June 18, 2024

A fix was provided via #181, but no tests are there, so I cannot merge it.

from cache.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.