Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalidating Inconsistencies #18

Open
XedinUnknown opened this issue Mar 28, 2017 · 2 comments
Open

Invalidating Inconsistencies #18

XedinUnknown opened this issue Mar 28, 2017 · 2 comments

Comments

@XedinUnknown
Copy link

XedinUnknown commented Mar 28, 2017

In a few places on the page about invalidation, it says that the invalidation method is set by passing additional values to "Item->get", such as:

Defining which method to use done by passing an Invalidation constant to the Item->get() class when it retrieves it's value

There's also a mistake there, calling a method a class. In other instances, the method doesn't have parentheses at the end, such as here:

When this method is used Item->get takes one additional argument

In the examples no additional values are passed to that method. Instead, a method not mentioned before is invoked, such as:

$userInfo->setInvalidationMethod(Stash\Invalidation::OLD);

I still cannot understand how to control invalidation because of this. Also, you may want to replace things like "Item->get" with ItemInterface#get(), e.g. including proper inline code and displaying it as such.

@alexbowers
Copy link
Contributor

We just ran across this issue at work.

I will have an attempt at rewriting some documentation soon.

Any help would be appreciated.

Feedback / thoughts @tedivm @XedinUnknown .

Thanks.

@alexbowers
Copy link
Contributor

alexbowers commented Apr 24, 2017

The issue we ran across was how to actually change invalidation methods.

The documentation is completely wrong in this regard.

<?php
    $item = $pool->getItem('Test');

// Get the data from the cache using the "Invalidation::OLD" technique for
// dealing with stampedes
$userInfo = $item->get();
$userInfo->setInvalidationMethod(Stash\Invalidation::OLD);

// Check to see if the cache missed, which could mean that it either didn't
// exist or was stale. If another process is regenerating this value and
// there is a stored value available then this function will return a hit.
if(!$item->isHit())
{
    // Mark this instance as the one regenerating the cache. Because our
    // protection method is Invalidation::OLD other Stash instances will
    // use the old value and count it as a hit.
    $item->lock();

    // Run the relatively expensive code.
    $userInfo = loadUserInfoFromDatabase($id);

    // Store the expensive code so the next time it doesn't miss. The store
    // function marks the stampede as over for now, so other Stash items
    // will begin working as normal.
    $pool->save($item->set($userInfo));

}

$userInfo is the variable containing the array (or whatever), that Redis has stored. It is not necessarily an object, and it is certainly not an object that is usable as a Stash instance.

I think this is supposed to be $item.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants