PHPackages                             gregoriohc/static-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. gregoriohc/static-cache

ActiveLibrary

gregoriohc/static-cache
=======================

PHP simple static cache class

v1.0.1(4y ago)06071MITPHPPHP ~5.6|~7.0|~8.0

Since Feb 4Pushed 4y ago1 watchersCompare

[ Source](https://github.com/gregoriohc/static-cache)[ Packagist](https://packagist.org/packages/gregoriohc/static-cache)[ Docs](https://github.com/gregoriohc/static-cache)[ RSS](/packages/gregoriohc-static-cache/feed)WikiDiscussions master Synced 1mo ago

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

static-cache
============

[](#static-cache)

[![Latest Version on Packagist](https://camo.githubusercontent.com/806bc61029a68f00857b4025f951f82cac6f57a35e4fc624a91141d243657349/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f677265676f72696f68632f7374617469632d63616368652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/gregoriohc/static-cache)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/dfc0f07e7a67e4d14763b3f6ada5d5185d3ef6753d042b598e77ee6c1c0122c5/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f677265676f72696f68632f7374617469632d63616368652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/gregoriohc/static-cache)[![Coverage Status](https://camo.githubusercontent.com/7c8570c5d3fb94153435d45f972e7524492ba4b7400d68a617175199d2516dc6/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f677265676f72696f68632f7374617469632d63616368652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/gregoriohc/static-cache/code-structure)[![Quality Score](https://camo.githubusercontent.com/e9651d2aa5774e0f25a9dfb2d9e54a2982f2462022ba311a61c7187e058bd58d/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f677265676f72696f68632f7374617469632d63616368652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/gregoriohc/static-cache)[![Total Downloads](https://camo.githubusercontent.com/38e1fac80e6afff70ae650a6554c04a7742a5ed0c525587c244f77031128d2e8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f677265676f72696f68632f7374617469632d63616368652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/gregoriohc/static-cache)

PHP simple static cache class

Install
-------

[](#install)

Via Composer

```
$ composer require gregoriohc/static-cache
```

Usage
-----

[](#usage)

### Checking for item existence

[](#checking-for-item-existence)

```
if (Cache::has('key')) {
    // ...
}
```

### Storing item

[](#storing-item)

```
Cache::set('key', 'value');
```

### Retrieving item

[](#retrieving-item)

```
$value = Cache::get('key');
```

If you wish, you may pass a second argument to the `get` method specifying the default value you wish to be returned if the item doesn't exist:

```
$value = Cache::get('key', 'default');
```

You may even pass a `Closure` as the default value. The result of the `Closure` will be returned if the specified item does not exist in the cache:

```
Cache::get('key', function() {
    return 'value';
});
```

### Retrieve and store item

[](#retrieve-and-store-item)

Sometimes you may wish to retrieve an item from the cache, but also store a default value if the requested item doesn't exist. You may do this using the `remember` method:

```
Cache::remember('key', function() {
    return 'value';
});
```

If the item does not exist in the cache, the Closure passed to the remember method will be executed and its result will be placed in the cache.

### Removing item

[](#removing-item)

```
Cache::forget('key');
```

Testing
-------

[](#testing)

```
$ composer test
```

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Socialware
----------

[](#socialware)

You're free to use this package, but if it makes it to your production environment I highly appreciate you sharing it on any social network.

Credits
-------

[](#credits)

- [Gregorio Hernández Caso](https://github.com/gregoriohc)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity69

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

Total

2

Last Release

1805d ago

PHP version history (2 changes)v1.0.0PHP ~5.6|~7.0

v1.0.1PHP ~5.6|~7.0|~8.0

### Community

Maintainers

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

---

Top Contributors

[![gregoriohc](https://avatars.githubusercontent.com/u/566841?v=4)](https://github.com/gregoriohc "gregoriohc (2 commits)")

---

Tags

static-cachegregoriohc

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/gregoriohc-static-cache/health.svg)

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

###  Alternatives

[silverstripe/staticpublishqueue

Static publishing queue to create static versions of pages for enhanced performance and security

45135.4k4](/packages/silverstripe-staticpublishqueue)

PHPackages © 2026

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