WordPress.org

Ready to get started?Download WordPress

Forums

Memcached Object Cache
[resolved] 'checkthedatabaseplease' == $value is true for int(0) (6 posts)

  1. Joe Hoyle
    Human Made
    Posted 1 year ago #

    I am not sure why the 'checkthedatabaseplease' is there, but if you are trying to store / get "int(0)" as the data, then this check succeeds in both places, when I presume it should not. 'checkthedatabaseplease' == 0 is bool(true).

    This means it is not possible to store int(0) in object cache.

    http://wordpress.org/extend/plugins/memcached/

  2. Matt Martz
    Member
    Plugin Author

    Posted 1 year ago #

    Your assumption is incorrect. We are comparing 'checkthedatabaseplease' against the value retrieved by memcached. And 'checkthedatabaseplease' does not evaluate to 0.

    The actual code snippets are:

    WP_Object_Cache::get

    if ( 'checkthedatabaseplease' === $value ) {
    			unset( $this->cache[$key] );
    			$value = false;
    		}

    WP_Object_Cache::set

    if ( isset($this->cache[$key]) && ('checkthedatabaseplease' === $this->cache[$key]) )
    			return false;

    So in your case for WP_Object_Cache::get, it would be performing the following evaluation:

    if ( 'checkthedatabaseplease' === 0 ) { which would return false, not true, since they are obviously not the same values.

    This allows us to store a value of 'checkthedatabaseplease' in memcached, to get the calling function to believe no data was returned and to look at the database for the correct data.

  3. Joe Hoyle
    Human Made
    Posted 1 year ago #

    Forgive me for my ignorance, but I really don't see how I am incorrect here.

    >> if ( 'checkthedatabaseplease' === 0 ) { which would return false, not true, since they are obviously not the same values.

    That's not what it does, it does if ( 'checkthedatabaseplease' == 0 ) which is (bool) true

  4. Matt Martz
    Member
    Plugin Author

    Posted 1 year ago #

    Ah, I see where you and I are on different pages. Apparently that change was fixed 13 months ago in the development version ( http://plugins.trac.wordpress.org/changeset?reponame=&new=427207%40memcached%2Ftrunk%2Fobject-cache.php&old=425137%40memcached%2Ftrunk%2Fobject-cache.php ), however we haven't pushed a new release in 15 months.

    I will push a new release soon.

  5. Matt Martz
    Member
    Plugin Author

    Posted 1 year ago #

    Ok, I have tagged a new release. 2.0.2 is showing up in the repo now.

  6. Joe Hoyle
    Human Made
    Posted 1 year ago #

    Ahh great, thanks Matt!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.