PHP simple static cache class

v1.0.1 2021-06-08 18:53 UTC

This package is auto-updated.

Last update: 2022-06-08 21:11:47 UTC


Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

PHP simple static cache class


Via Composer

$ composer require gregoriohc/static-cache


Checking for item existence

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

Storing item

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

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

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



$ composer test

Change log

Please see CHANGELOG for more information on what has changed recently.


Please see CONTRIBUTING for details.


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


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.



The MIT License (MIT). Please see License File for more information.