PHPackages                             mazz/global-static-cache-manager - 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. mazz/global-static-cache-manager

ActiveLibrary

mazz/global-static-cache-manager
================================

A global static cache manager for php

1.1.2(5y ago)35.3k1MITPHPPHP &gt;=5.3.0CI failing

Since Jan 21Pushed 5y ago1 watchersCompare

[ Source](https://github.com/MazzMazz/Static-Cache-Manager-for-PHP)[ Packagist](https://packagist.org/packages/mazz/global-static-cache-manager)[ RSS](/packages/mazz-global-static-cache-manager/feed)WikiDiscussions master Synced today

READMEChangelog (5)Dependencies (3)Versions (5)Used By (0)

Static Cache Manager for PHP
============================

[](#static-cache-manager-for-php)

About
-----

[](#about)

In some applications it is very useful to initialize a set of data and store it in a static variable to be availbale applicationwide without having to initialize it everytime it is needed. Having a lot of such static cache variables can lead to bad code quality.

The `Global-Static-Cache-Manager` introduces a central manager to handle multiple static caches.

The StaticCacheContainer uses the [PSR-11 Interface](https://www.php-fig.org/psr/psr-11/)
The StaticCache uses the [PSR-16 Interface](https://www.php-fig.org/psr/psr-16/)

Install
-------

[](#install)

Just add the composer package

`composer require mazz/php-global-static-cache-manager`

[What is composer?](https://getcomposer.org/)

Usage
-----

[](#usage)

Get instance of the global `StaticCacheContainer` and get the Cache with Key `currency_cache`. If no cache with this key is available a new `StaticCache` for the given key is created and returned.

```
// Receive the Cache with the currency_cache
$currencyCache = StaticCacheContainer::getInstance()->get('currency_cache');

// Fill the cache one by one
$currencyCache->set(1, 'currency1');
$currencyCache->set(2, 'currency2');
$currencyCache->set(3, 'currency3');

// It is also possible to fill multiple at once
$currencyCache->setMultiple([
    4 => 'currency4',
    5 => 'currency5',
]);
```

You then can simply access the cache in any part of your application

```
// Get the currency which is saved on index 4
$currency = StaticCacheContainer::getInstance()->get('currency_cache')->get(4);

// it is also possible to set a default value
$currency = StaticCacheContainer::getInstance()->get('currency_cache')->get(42, 'defaultCurrency');

// or load multiple keys at once
$currency = StaticCacheContainer::getInstance()->get('currency_cache')->get([1,2,3);
```

You may also check if the cache is already initialized. Usefull if you want to fill the cache only once.

```
// Returns true if cache with the key my_cache_key exists, false otherwise
if(!StaticCacheContainer::getInstance()->has('my_cache_key')) {
    // you may want to fill the cache here
}
```

The `StaticCache` introduces also other useful functions: `has($key)`, `clear()`, `delete($key)`

### License

[](#license)

This project is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

###  Health Score

30

—

LowBetter than 65% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

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

Total

4

Last Release

1922d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7afc6c89f2facca48931fb8ab4a045049a1a5a9aafc5871907f55e58dee00eda?d=identicon)[MazzMazz](/maintainers/MazzMazz)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mazz-global-static-cache-manager/health.svg)

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

###  Alternatives

[laravel/framework

The Laravel Framework.

34.6k509.9M17.0k](/packages/laravel-framework)[cakephp/cakephp

The CakePHP framework

8.8k18.5M1.6k](/packages/cakephp-cakephp)[illuminate/contracts

The Illuminate Contracts package.

704122.9M10.0k](/packages/illuminate-contracts)[thecodingmachine/graphqlite

Write your GraphQL queries in simple to write controllers (using webonyx/graphql-php).

5723.1M30](/packages/thecodingmachine-graphqlite)[moonshine/moonshine

Laravel administration panel

1.3k217.1k59](/packages/moonshine-moonshine)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

728272.9k17](/packages/civicrm-civicrm-core)

PHPackages © 2026

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