PHPackages                             erikbooij/cache-scheduler - 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. erikbooij/cache-scheduler

ActiveLibrary[Caching](/categories/caching)

erikbooij/cache-scheduler
=========================

A simple way to get the most out of your cache TTL.

1.0.0(7y ago)322MITPHPPHP ^7.1

Since Feb 24Pushed 1y ago2 watchersCompare

[ Source](https://github.com/ErikBooij/php-cache-scheduler)[ Packagist](https://packagist.org/packages/erikbooij/cache-scheduler)[ RSS](/packages/erikbooij-cache-scheduler/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (2)Versions (3)Used By (0)

This *Cache Scheduler* is a library that allows you to vary your cache TTLs according to a self defined schedule. I've written [a little blog post on why you might want to consider that](https://dev.to/erikbooij/getting-the-most-out-of-server-side-caching-35o7).

Usage is simple:

1. install it with Composer:

    ```
    $ composer require erikbooij/cache-scheduler
    ```
2. Create a schedule and scheduler:

    ```
    $schedule = (new Schedule)
        ->requireUpToDateDataFrom(Schedule::MON, 8, 0)
        ->allowStaleDataFrom(Schedule::MON, 17, 30)
        ->requireUpToDateDataFrom(Schedule::TUE, 8, 0)
        ->allowStaleDataFrom(Schedule::TUE, 17, 30)
        ->requireUpToDateDataFrom(Schedule::WED, 8, 0)
        ->allowStaleDataFrom(Schedule::WED, 17, 30)
        ->requireUpToDateDataFrom(Schedule::THU, 8, 0)
        ->allowStaleDataFrom(Schedule::THU, 17, 30)
        ->requireUpToDateDataFrom(Schedule::FRI, 8, 0)
        ->allowStaleDataFrom(Schedule::FRI, 17, 30);

    // Create the scheduler, passing it a SystemClock instance to interface with system time
    $scheduler = (new Scheduler(new SystemClock))
        ->setSchedule($schedule)
        ->setExpirationSpread(ExpirationSpread::minutes(30));
    ```
3. Use the scheduler to determine the allowed lifespan of your item in cache:

    ```
    $cache->set('cache-key', 'cache-value', $scheduler->calculateTimeToLive(3600));
    ```

The number passed as the first argument to `->calculateTimeToLive()` is the cache TTL if your data is currently require to be up-to-date (the default TTL).

Instead of attaching the schedule and expiration spread to the scheduler as in the example, you can also pass that as the second and third argument respectively to `->calculateTimeToLive()`. If you use both, the method arguments will override the values attached to the scheduler.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance26

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90% 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

Unknown

Total

1

Last Release

2635d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b80ba040200fdd50e1a03026385e0870a1f5f7b2d403278bc415ce362f867d0b?d=identicon)[ErikBooij](/maintainers/ErikBooij)

---

Top Contributors

[![ErikBooij](https://avatars.githubusercontent.com/u/5747956?v=4)](https://github.com/ErikBooij "ErikBooij (9 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/erikbooij-cache-scheduler/health.svg)

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

###  Alternatives

[predis/predis

A flexible and feature-complete Redis/Valkey client for PHP.

7.8k305.7M2.4k](/packages/predis-predis)[snc/redis-bundle

A Redis bundle for Symfony

1.0k39.4M67](/packages/snc-redis-bundle)[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)

PHPackages © 2026

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