PHPackages                             vaibhavpandeyvpz/godam - 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. vaibhavpandeyvpz/godam

ActiveLibrary[Caching](/categories/caching)

vaibhavpandeyvpz/godam
======================

A modern, PSR-6 and PSR-16 compliant caching library for PHP 8.2+ with support for multiple storage backends.

2.0.1(6mo ago)1974↓62.5%11MITPHPPHP ^8.2CI failing

Since Jan 26Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/vaibhavpandeyvpz/godam)[ Packagist](https://packagist.org/packages/vaibhavpandeyvpz/godam)[ Docs](https://github.com/vaibhavpandeyvpz/godam)[ RSS](/packages/vaibhavpandeyvpz-godam/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (4)Versions (5)Used By (1)

vaibhavpandeyvpz/godam
======================

[](#vaibhavpandeyvpzgodam)

A modern, PSR-6 and PSR-16 compliant caching library for PHP 8.2+ with support for multiple storage backends.

> **Godam** (`गोदाम`) means "Warehouse" in Hindi

[![Latest Version](https://camo.githubusercontent.com/7a6571420be1f62658aa7bf3bedb0bad6d01122d3f02fc458a6361436c9e49dd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7661696268617670616e64657976707a2f676f64616d2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vaibhavpandeyvpz/godam)[![Downloads](https://camo.githubusercontent.com/9670d312a0244b0d6b72c78e4bc079cd5c22260eba404482718006472310ab73/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7661696268617670616e64657976707a2f676f64616d2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vaibhavpandeyvpz/godam)[![PHP Version](https://camo.githubusercontent.com/53ab9ed97e988f8d3ada816a50d3cd614f4bc5955fee2c17f3e66ffdcda0e106/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7661696268617670616e64657976707a2f676f64616d2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vaibhavpandeyvpz/godam)[![License](https://camo.githubusercontent.com/5ce66a39ced2cd6f2114674d2c8156dab305133978d0e78a6b0013c57cdf722f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7661696268617670616e64657976707a2f676f64616d2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Build Status](https://camo.githubusercontent.com/32ca0efedb72f3b31d8513237afaa2680abc4eecd466c56521ec870b9570b634/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7661696268617670616e64657976707a2f676f64616d2f74657374732e796d6c3f6272616e63683d6d6173746572267374796c653d666c61742d737175617265)](https://github.com/vaibhavpandeyvpz/godam/actions)

Features
--------

[](#features)

- ✅ **PSR-6** (Cache Item Pool Interface) compliant
- ✅ **PSR-16** (Simple Cache Interface) compliant
- ✅ Multiple storage backends: Memory, FileSystem, Redis, Memcache, Predis
- ✅ TTL (Time To Live) support with flexible expiration
- ✅ Type-safe with PHP 8.2+ features
- ✅ 100% test coverage
- ✅ Zero dependencies (except PSR interfaces)

Installation
------------

[](#installation)

Install via Composer:

```
composer require vaibhavpandeyvpz/godam
```

### Optional Dependencies

[](#optional-dependencies)

For Redis support, you can use either:

- `ext-redis` (PECL extension)
- `predis/predis` (pure PHP client)

For Memcache support:

- `ext-memcache` (PECL extension)

Storage Backends
----------------

[](#storage-backends)

Godam supports multiple storage backends through the `StoreInterface`:

### MemoryStore

[](#memorystore)

In-memory cache that stores data in PHP arrays. Perfect for testing or single-request caching.

```
use Godam\Store\MemoryStore;

$store = new MemoryStore();
```

### FileSystemStore

[](#filesystemstore)

File-based cache that stores data on disk. Ideal for applications without external cache servers.

```
use Godam\Store\FileSystemStore;

$store = new FileSystemStore('/path/to/cache/directory');
```

### RedisStore

[](#redisstore)

Redis cache using the `ext-redis` extension.

```
use Godam\Store\RedisStore;

$redis = new Redis();
$redis->connect('localhost', 6379);
$store = new RedisStore($redis);
```

### PredisStore

[](#predisstore)

Redis cache using the `predis/predis` library (pure PHP, no extension required).

```
use Godam\Store\PredisStore;
use Predis\Client;

$redis = new Client('tcp://127.0.0.1:6379');
$store = new PredisStore($redis);
```

### MemcacheStore

[](#memcachestore)

Memcache cache using the `ext-memcache` extension.

```
use Godam\Store\MemcacheStore;

$memcache = new Memcache();
$memcache->connect('localhost', 11211);
$store = new MemcacheStore($memcache);
```

Usage
-----

[](#usage)

### PSR-16 Simple Cache Interface

[](#psr-16-simple-cache-interface)

The `Cache` class provides a simple, straightforward caching interface:

```
use Godam\Cache;
use Godam\Store\MemoryStore;

$cache = new Cache(new MemoryStore());

// Store a value with TTL (time to live in seconds)
$cache->set('user:123', ['name' => 'John', 'email' => 'john@example.com'], 3600);

// Retrieve a value
$user = $cache->get('user:123');

// Get with default value if key doesn't exist
$user = $cache->get('user:456', ['name' => 'Guest']);

// Check if a key exists
$exists = $cache->has('user:123');

// Delete a single key
$cache->delete('user:123');

// Delete multiple keys
$cache->deleteMultiple(['user:123', 'user:456']);

// Store multiple values at once
$cache->setMultiple([
    'key1' => 'value1',
    'key2' => 'value2',
], 3600);

// Get multiple values at once
$values = $cache->getMultiple(['key1', 'key2'], []);

// Clear all cache
$cache->clear();
```

### PSR-6 Cache Item Pool Interface

[](#psr-6-cache-item-pool-interface)

The `CacheItemPool` class provides a more advanced caching interface with cache items:

```
use Godam\CacheItemPool;
use Godam\Store\FileSystemStore;

$pool = new CacheItemPool(new FileSystemStore(__DIR__ . '/cache'));

// Get a cache item
$item = $pool->getItem('user:123');

if ($item->isHit()) {
    // Cache hit - item exists and is not expired
    $user = $item->get();
} else {
    // Cache miss - set the value
    $item->set(['name' => 'John', 'email' => 'john@example.com']);

    // Set expiration time (in seconds)
    $item->expiresAfter(3600);

    // Or set expiration to a specific date/time
    // $item->expiresAt(new \DateTime('+1 hour'));

    // Save the item
    $pool->save($item);
}

// Get multiple items at once
$items = $pool->getItems(['user:123', 'user:456']);

// Save a deferred item (will be saved on commit)
$item = $pool->getItem('user:789');
$item->set(['name' => 'Jane']);
$item->expiresAfter(1800);
$pool->saveDeferred($item);

// Commit all deferred items
$pool->commit();

// Delete an item
$pool->deleteItem('user:123');

// Delete multiple items
$pool->deleteItems(['user:123', 'user:456']);

// Clear all items
$pool->clear();
```

### TTL (Time To Live) Examples

[](#ttl-time-to-live-examples)

```
use Godam\Cache;
use Godam\Store\MemoryStore;

$cache = new Cache(new MemoryStore());

// Cache for 1 hour (3600 seconds)
$cache->set('key1', 'value1', 3600);

// Cache forever (no expiration)
$cache->set('key2', 'value2', null);

// Cache for 30 minutes
$cache->set('key3', 'value3', 1800);

// Using DateInterval
$cache->set('key4', 'value4', new \DateInterval('PT1H')); // 1 hour
```

Advanced Usage
--------------

[](#advanced-usage)

### Custom Storage Backend

[](#custom-storage-backend)

You can create your own storage backend by implementing the `StoreInterface`:

```
use Godam\StoreInterface;

class CustomStore implements StoreInterface
{
    public function get(string $key): mixed { /* ... */ }
    public function set(string $key, mixed $value, ?int $ttl = null): bool { /* ... */ }
    public function delete(string $key): bool { /* ... */ }
    public function clear(): bool { /* ... */ }
    public function has(string $key): bool { /* ... */ }
}
```

### Error Handling

[](#error-handling)

```
use Godam\Cache;
use Godam\InvalidArgumentException;

try {
    $cache->set('', 'value'); // Empty key throws InvalidArgumentException
} catch (InvalidArgumentException $e) {
    // Handle invalid key
}
```

Requirements
------------

[](#requirements)

- PHP &gt;= 8.2
- PSR Cache interfaces (automatically installed via Composer)

Testing
-------

[](#testing)

Run the test suite:

```
composer test
```

Or with PHPUnit directly:

```
vendor/bin/phpunit
```

License
-------

[](#license)

This project is open-sourced software licensed under the [MIT License](LICENSE).

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

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

Links
-----

[](#links)

- [GitHub Repository](https://github.com/vaibhavpandeyvpz/godam)
- [Packagist](https://packagist.org/packages/vaibhavpandeyvpz/godam)
- [PSR-6 Specification](https://www.php-fig.org/psr/psr-6/)
- [PSR-16 Specification](https://www.php-fig.org/psr/psr-16/)

###  Health Score

48

—

FairBetter than 93% of packages

Maintenance69

Regular maintenance activity

Popularity19

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity79

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

Total

4

Last Release

183d ago

Major Versions

1.1 → 2.0.02025-12-27

PHP version history (2 changes)1.0PHP ^5.3 || ^7.0

2.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/4cf0d090043e41bf330d9ef1d0e7e799f1946145ddb3569ba38a003d47929378?d=identicon)[vaibhavpandeyvpz](/maintainers/vaibhavpandeyvpz)

---

Top Contributors

[![vaibhavpandeyvpz](https://avatars.githubusercontent.com/u/6647172?v=4)](https://github.com/vaibhavpandeyvpz "vaibhavpandeyvpz (15 commits)")

---

Tags

cachepsr-16psr-6

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/vaibhavpandeyvpz-godam/health.svg)

```
[![Health](https://phpackages.com/badges/vaibhavpandeyvpz-godam/health.svg)](https://phpackages.com/packages/vaibhavpandeyvpz-godam)
```

###  Alternatives

[laminas/laminas-cache

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

1077.3M154](/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.3M27](/packages/cache-simple-cache-bridge)[infocyph/intermix

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

137.7k2](/packages/infocyph-intermix)[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)
