PHPackages                             shasoft/psr-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. [Caching](/categories/caching)
4. /
5. shasoft/psr-cache

ActiveLibrary[Caching](/categories/caching)

shasoft/psr-cache
=================

PSR-16 cache adapters

v1.1.1(2y ago)0204MITPHP

Since Oct 30Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/shasoft/psr-cache)[ Packagist](https://packagist.org/packages/shasoft/psr-cache)[ RSS](/packages/shasoft-psr-cache/feed)WikiDiscussions main Synced yesterday

READMEChangelog (4)Dependencies (4)Versions (5)Used By (4)

shasoft/psr-cache
=================

[](#shasoftpsr-cache)

Класс для работы с КЭШем на основе [PSR-16](https://www.php-fig.org/psr/psr-16/)

Пакет реализует два класса

1. **Shasoft\\PsrCache\\CacheItemPool** implements **Psr\\Cache\\CacheItemInterface** - класс объекта работы с КЭШем
2. **Shasoft\\PsrCache\\PsrCache** implements **Psr\\Cache\\CacheItemInterface** - класс элемента КЭШа

```
    // Создать объект для работы с КЭШем
    $cache = new Shasoft\PsrCache\CacheItemPool(
        new Shasoft\PsrCache\Adapter\CacheAdapter()
    );
    // Получить элемент КЭШа
    $itemCache = cache->getItem('myKey');
    // Если элемент не найден в КЖШе
    if( !$itemCache->isHit() ) {
        // то установить значение
        $itemCache->set('valueCacheItem');
        // и сохранить в КЭШ
        $cache->save($itemCache);
    }
    // Вывести значение
    echo $itemCache->get();
```

В качестве параметра конструктора класс объекта работы с КЭШем принимает объект адаптера. На текущий момент доступны следующие адаптеры

1. **Shasoft\\PsrCache\\Adapter\\CacheAdapterArray** - КЭШирование в php массиве
2. **Shasoft\\PsrCache\\Adapter\\CacheAdapterFilesystem** - КЭШирование в файловой системе

Для создание своего адаптера необходимо создать свой класс наследовав его от **Shasoft\\PsrCache\\Adapter\\CacheAdapter** и определить его абстрактные методы:

```
abstract class CacheAdapter
{
    // Получить значения (Если $has=true, то только проверить наличие значения.
    // Т.е. вернуть либо false, либо true)
    abstract public function get(array $keys, bool $has): array;
    // Удалить указанные значения
    abstract public function delete(array $keys): bool;
    // Удалить все значения
    abstract public function clear(): bool;
    // Сохранить элементы ['key1'=>'value11, 'key2'=>'value12, ...]
    // Возвращает список ключей успешно сохраненных элементов
    abstract public function save(array $items): array;
}
```

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance43

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity46

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

Total

4

Last Release

753d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2348125?v=4)[Shasoft](/maintainers/shasoft)[@shasoft](https://github.com/shasoft)

---

Tags

cachepsr-16php-array

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/shasoft-psr-cache/health.svg)

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

###  Alternatives

[symfony/cache

Provides extended PSR-6, PSR-16 (and tags) implementations

4.2k373.5M3.3k](/packages/symfony-cache)[laminas/laminas-cache

Caching implementation with a variety of storage options, as well as codified caching strategies for callbacks, classes, and output

1077.3M153](/packages/laminas-laminas-cache)[cache/simple-cache-bridge

A PSR-6 bridge to PSR-16. This will make any PSR-6 cache compatible with SimpleCache.

433.3M28](/packages/cache-simple-cache-bridge)[infocyph/intermix

A lightweight PHP DI container, invoker, serializer, and utility toolkit.

137.7k2](/packages/infocyph-intermix)[webarchitect609/bitrix-cache

Comfortable fluent interface for Bitrix cache. Anti-stampede cache protection.

2831.6k8](/packages/webarchitect609-bitrix-cache)[codeigniter4/cache

PSR-6 and PSR-16 Cache Adapters for CodeIgniter 4

1422.1k](/packages/codeigniter4-cache)

PHPackages © 2026

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