PHPackages                             sitegeist/stalemate - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. sitegeist/stalemate

ActiveNeos-package[Caching](/categories/caching)

sitegeist/stalemate
===================

Cache with stale period and asynchronous updates

v1.0.2(10mo ago)117.5k↓35.7%GPL-3.0+PHPCI passing

Since Oct 14Pushed 10mo ago2 watchersCompare

[ Source](https://github.com/sitegeist/Sitegeist.StaleMate)[ Packagist](https://packagist.org/packages/sitegeist/stalemate)[ RSS](/packages/sitegeist-stalemate/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (4)Versions (4)Used By (0)

Sitegeist.StaleMate
===================

[](#sitegeiststalemate)

Varnish like cache for Neos.Flow with asynchronous updates that returns stale results in the meantime
-----------------------------------------------------------------------------------------------------

[](#varnish-like-cache-for-neosflow-with-asynchronous-updates-that-returns-stale-results-in-the-meantime)

This package implements cache that will return stale values for a configurable time while the cache values are updated asynchronously. Such behavior is well known from the varnish cache but not common in php.

The core concept is that the staleMateCache gets an `identifier` and `closure` for generating the required information if it cannot be found in the cache. The closure is called immediately if no cached result is found. If a result is found the cached result is returned.

In case the cached item is older than the intended lifetime the stale item is still returned immediately but the closure is scheduled for evaluating during the shutdown of the flow application and thus after the response has been sent to the user.

### Authors &amp; Sponsors

[](#authors--sponsors)

- Melanie Wüst -
- Martin Ficzel -

*The development and the public-releases of this package is generously sponsored by our employer .*

Usage
-----

[](#usage)

The StaleMate cache is injected from flow.

```
    use \Sitegeist\StaleMate\Cache\ClosureCache as StaleMateCache;

    /**
     * @var VariableFrontend
     */
    protected $cache;

    /**
     * @var StaleMateCache
     */
    protected $staleMateCache;

    /**
     * @param VariableFrontend $cache
     * @return void
     */
    public function injectCache(VariableFrontend $cache): void
    {
        $this->cache = $cache;
    }

    public function initializeObject()
    {
        $staleMateCache = new \Sitegeist\StaleMate\Cache\ClosureCache(
            $this->cache, // the variable frontend to cache the data in
            8600, // lifetime for the items
            4300, // gracePeriod where items are updated asynchronous
            60 // lockPeriod for asynchronous updates
        );
    }
```

The cache is then called via the `resolve` method with an `identifier` and a`closure`. Please note that the closure cannot have arguments but instead may `use` variables from the context the method is called from.

```
    $result = $this->staleMateCache->resolve(
        $cacheId, // identifier used to store the result, has to be unique
        function () use ($stuffThatIsNeeded) {
            $response = ... some expensive operation ...
            return $response;
        }, // closure to generate the result if no result is in the cache
        ['someTag'], // tags for the cache item
        86400, // lifetime of the cached result until a refresh is needed
        43200, // gracePeriod after lifetime where an update is performed async and the stale result is used
        60 // lockPeriod for asynchronous updates
    );
```

Installation
------------

[](#installation)

Sitegeist.StaleMate is available via packagist. Just run `composer require sitegeist/stalemate` to install it. We use semantic-versioning so every breaking change will increase the major-version number.

Comparison to Symfony Cache Contracts
-------------------------------------

[](#comparison-to-symfony-cache-contracts)

The approach implemented here is somewhat similar to the [symfony cache contracts](https://symfony.com/doc/current/components/cache.html#cache-contracts)but deviates in a specific way. Symfony Cache Contracts will roll a dice to upgrade cache entries before they expire to prevent mass invalidation and recomputation. Stalemate on the other hand will return the cached item and recompute the value after the response was sent to the user.

Contribution
------------

[](#contribution)

We will gladly accept contributions. Please send us pull requests.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance54

Moderate activity, may be stable

Popularity27

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~998 days

Total

2

Last Release

314d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/829b4ccb51e8cff3c1e4b59d60cfe8d1b86f6d77fc31a6b3fc99227f432542ca?d=identicon)[mficzel](/maintainers/mficzel)

---

Top Contributors

[![mficzel](https://avatars.githubusercontent.com/u/1309380?v=4)](https://github.com/mficzel "mficzel (24 commits)")

---

Tags

neoscms

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/sitegeist-stalemate/health.svg)

```
[![Health](https://phpackages.com/badges/sitegeist-stalemate/health.svg)](https://phpackages.com/packages/sitegeist-stalemate)
```

###  Alternatives

[react/cache

Async, Promise-based cache interface for ReactPHP

444112.4M40](/packages/react-cache)[wp-media/wp-rocket

Performance optimization plugin for WordPress

7431.3M3](/packages/wp-media-wp-rocket)[illuminate/cache

The Illuminate Cache package.

12835.6M1.4k](/packages/illuminate-cache)[colinmollenhour/php-redis-session-abstract

A Redis-based session handler with optimistic locking

6325.6M14](/packages/colinmollenhour-php-redis-session-abstract)[cheprasov/php-redis-client

Php client for Redis. It is a fast, fully-functional and user-friendly client for Redis, optimized for performance. RedisClient supports the latest versions of Redis starting from 2.6 to 6.0

1281.2M21](/packages/cheprasov-php-redis-client)[amphp/redis

Efficient asynchronous communication with Redis servers, enabling scalable and responsive data storage and retrieval.

165634.7k44](/packages/amphp-redis)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
