Skip to content

Commit

Permalink
Moved precompute to top now that it's the default
Browse files Browse the repository at this point in the history
  • Loading branch information
tedivm committed May 18, 2014
1 parent 1acb16e commit 039aaec
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions Invalidation.rst
Expand Up @@ -49,12 +49,30 @@ data. Old values can be reused, new values set, or the cache can even be
refreshed before it gets stale. Different methods can be set by passing the
appropriate constant to Stash's "get" function.


Precompute
----------

The personal favorite method of the Stash developers, this method causes Stash
to recalculate the cached item _before_ it misses.

When this method is used Stash->get takes one additional argument, the amount of
time (in seconds) before the expiration when it should regenerate the cache.

.. code-block:: php
<?php
// five minutes before the cache expires one instance will return a miss,
// causing the cache to regenerate.
$item->get(Item::SP_PRECOMPUTE, 300);
None
----

By default Stash simply returns true for the "isMiss" function whenever the
cache is invalid, meaning multiple cache misses can occur at once and stampede
protection is not enabled. While not needed, this method can be explicitly set.
protection is not enabled.

.. code-block:: php
Expand All @@ -69,22 +87,6 @@ protection is not enabled. While not needed, this method can be explicitly set.
// returns false if the item is missing or expired, no exceptions.
$item->isMiss();
Precompute
----------

The personal favorite method of the Stash developers, this method causes Stash
to recalculate the cached item _before_ it misses.

When this method is used Stash->get takes one additional argument, the amount of
time (in seconds) before the expiration when it should regenerate the cache.

.. code-block:: php
<?php
// five minutes before the cache expires one instance will return a miss,
// causing the cache to regenerate.
$item->get(Item::SP_PRECOMPUTE, 300);
Old
---

Expand Down

0 comments on commit 039aaec

Please sign in to comment.