PHPackages                             koine/delayed-cache - 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. koine/delayed-cache

ActiveLibrary

koine/delayed-cache
===================

Delayed cache for php

v1.0.2(10y ago)05261MITPHPPHP &gt;=5.5

Since Sep 4Pushed 10y agoCompare

[ Source](https://github.com/koinephp/DelayedCache)[ Packagist](https://packagist.org/packages/koine/delayed-cache)[ RSS](/packages/koine-delayed-cache/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (5)Versions (4)Used By (0)

Koine Delayed Cache
===================

[](#koine-delayed-cache)

Delayed Cache is a wrapper for Zend Cache. Sometimes you have parallel requests want a cached result that was already started, but is still under construction. Delayed cache will wait until it is ready and then it will return the result for you.

Code information:

[![Build Status](https://camo.githubusercontent.com/7185b4a7f72b737a4c6850ff3c022b419fe5c46448e74003ba0078cabfb2a586/68747470733a2f2f7472617669732d63692e6f72672f6b6f696e657068702f44656c6179656443616368652e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/koinephp/DelayedCache)[![Coverage Status](https://camo.githubusercontent.com/65ff1f273560b5e32454e6532b39d38586ff192a1a2d04e21d2b75bee42c964a/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6b6f696e657068702f44656c6179656443616368652f62616467652e706e67)](https://coveralls.io/r/koinephp/DelayedCache)[![Code Climate](https://camo.githubusercontent.com/4511dcd1b9176abd20aa08ca678f6724e193307f7e6e49f7a72de772f31b6ebb/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6b6f696e657068702f44656c6179656443616368652e706e67)](https://codeclimate.com/github/koinephp/DelayedCache)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/d0dc628c4978d6b9ed5181c0f192bd2695448ed5f7014cc3a3dcdcb079cc58cf/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6b6f696e657068702f44656c6179656443616368652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/koinephp/DelayedCache/?branch=master)

Package information:

[![Latest Stable Version](https://camo.githubusercontent.com/46efc0a3678f8c7f4992ceb9d6f67905fe988b8ac41542906c388c3908733fae/68747470733a2f2f706f7365722e707567782e6f72672f6b6f696e652f64656c617965642d63616368652f762f737461626c652e737667)](https://packagist.org/packages/koine/delayed-cache)[![Total Downloads](https://camo.githubusercontent.com/770ae550f3e605cd8227a0d6ae080c49d6c3eeefc067a5a2d8e30e889fc37598/68747470733a2f2f706f7365722e707567782e6f72672f6b6f696e652f64656c617965642d63616368652f646f776e6c6f6164732e737667)](https://packagist.org/packages/koine/delayed-cache)[![Latest Unstable Version](https://camo.githubusercontent.com/e24100fb95553c700247c6f2479e6375d1d37bf16ab34f0c5dc4aefebccd2dfc/68747470733a2f2f706f7365722e707567782e6f72672f6b6f696e652f64656c617965642d63616368652f762f756e737461626c652e737667)](https://packagist.org/packages/koine/delayed-cache)[![License](https://camo.githubusercontent.com/034098c4472eda7f94c9cb14b0ed376fc1a18987ba5c35111a91b1483d04a834/68747470733a2f2f706f7365722e707567782e6f72672f6b6f696e652f64656c617965642d63616368652f6c6963656e73652e737667)](https://packagist.org/packages/koine/delayed-cache)[![Dependency Status](https://camo.githubusercontent.com/cb1c7d6db0ea862c2cac1a17408b38461291f07f3ea37c0c8d5e9bd56afc364d/68747470733a2f2f67656d6e617369756d2e636f6d2f6b6f696e657068702f44656c6179656443616368652e706e67)](https://gemnasium.com/koinephp/DelayedCache)

Installing
----------

[](#installing)

### Installing via Composer

[](#installing-via-composer)

Append the lib to your requirements key in your composer.json.

```
{
    // composer.json
    // [..]
    require: {
        // append this line to your requirements
        "koine/delayed-cache": "dev-master"
    }
}
```

### Alternative install

[](#alternative-install)

- Learn [composer](https://getcomposer.org). You should not be looking for an alternative install. It is worth the time. Trust me ;-)
- Follow [this set of instructions](#installing-via-composer)

Usage
-----

[](#usage)

```
$zendCache = $cache  = \Zend\Cache\StorageFactory::adapterFactory(
    'apc',
    array('ttl' => 3600)
);

$delayedCache = new \Koine\DelayedCache\DelayedCache($zendCache);
```

```
// index.php, second 10:00:00 am

$cacheKey = 'veryExpansiveCalculation';

$veryExpansiveCalculation = function () {
    sleep(60);

    return '42';
};

// hasItem returns true in the false time
if (!$delayedCache->hasItem($cacheKey)) {
    $delayedCache->setItem($cacheKey, $veryExpansiveCalculation);
}

$answer = $delayedCache->getItem($cacheKey);
echo 'answer is: ' . $answer;
```

```
// index.php, 10:00:10 am

$cacheKey = 'veryExpansiveCalculation';

$veryExpansiveCalculation = function () {
    sleep(60);

    return '42';
};

// although the result is not ready yet, hasItem will return true
if (!$delayedCache->hasItem($cacheKey)) {
    $delayedCache->setItem($cacheKey, $veryExpansiveCalculation);
}

// Waits 50 seconds until the building of the cache is done and then returns
// The $veryExpansiveCalculation callback will not be executed twice, unless the
// cache is cleared
$answer = $delayedCache->getItem($cacheKey);
echo 'answer is: ' . $answer;
```

Alternatively you can use the short method:

```
$cacheKey = 'veryExpansiveCalculation';

$veryExpansiveCalculation = function () {
    sleep(60);

    return '42';
};

// if cache is not set, it will set and then return the cached value
$answer = $delayedCache->getCachedItem($cacheKey, $veryExpansiveCalculation);
echo 'answer is: ' . $answer;
```

[![When it shines](https://camo.githubusercontent.com/ede1ef32c45e39ab952dab8142c76c420364ca8360b304a78780640566de9195/687474703a2f2f696d672e796f75747562652e636f6d2f76692f52577555696633733562342f302e6a7067)](http://www.youtube.com/watch?v=RWuUif3s5b4)

Issues/Features proposals
-------------------------

[](#issuesfeatures-proposals)

[Here](https://github.com/koinephp/delayed-cache/issues) is the issue tracker.

Contributing
------------

[](#contributing)

Only TDD code will be accepted. Please follow the [PSR-2 code standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md).

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

### How to run the tests:

[](#how-to-run-the-tests)

```
phpunit
```

### To check the code standard run:

[](#to-check-the-code-standard-run)

```
# Fixes code
./bin/php-cs-fix.sh

# outputs error
./bin/php-cs-fix.sh src true
./bin/php-cs-fix.sh test true
```

Lincense
--------

[](#lincense)

[MIT](MIT-LICENSE)

Authors
-------

[](#authors)

- [Marcelo Jacobus](https://github.com/mjacobus)

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

Established project with proven stability

 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 ~10 days

Total

3

Last Release

3880d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/226834?v=4)[Marcelo Jacobus](/maintainers/mjacobus)[@mjacobus](https://github.com/mjacobus)

---

Top Contributors

[![mjacobus](https://avatars.githubusercontent.com/u/226834?v=4)](https://github.com/mjacobus "mjacobus (27 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/koine-delayed-cache/health.svg)

```
[![Health](https://phpackages.com/badges/koine-delayed-cache/health.svg)](https://phpackages.com/packages/koine-delayed-cache)
```

###  Alternatives

[psliwa/php-pdf

Pdf and graphic files generator library for PHP.

336520.6k3](/packages/psliwa-php-pdf)[stroker/cache

Provides a full page cache solution for Laminas

6444.7k](/packages/stroker-cache)[stroker/form

ZF2 module for extending forms with live clientside validation

4157.1k](/packages/stroker-form)[magium/configuration-manager

Provides a generic plugable configuration management interface similar to Magento

2075.2k11](/packages/magium-configuration-manager)[soflomo/cache

Command line utility for cache management in Zend Framework 2

1410.9k](/packages/soflomo-cache)

PHPackages © 2026

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