dercoder/simple-cache-shared-memory

Maintainers

👁 DerCoder

Package info

github.com/dercoder/simple-cache-shared-memory

pkg:composer/dercoder/simple-cache-shared-memory

Statistics

Installs: 8

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.0 2024-07-18 11:41 UTC

Requires

Requires (Dev)

Suggests

  • ext-igbinary: For faster serialization of values

Provides

None

Conflicts

None

Replaces

None

MIT 1d48dd33dc9f3b3e521b2a3c7cccc8a0c8b9393b

  • Alexander Fedra <alexander.fedra.woop@example.com>

cacheshmsimple-cachepsr-16shared-memory

This package is auto-updated.

Last update: 2026-06-19 13:12:53 UTC


README

A simple cache implementation using shared memory in PHP.

Installation

You can install the package using Composer:

composer require dercoder/simple-cache-shared-memory

Usage

use DerCoder\SimpleCache\SharedMemory\SharedMemoryCache;
use Psr\SimpleCache\CacheInterface;

$cache = new SharedMemoryCache('1M'); // 1MB shared memory segment

// Set cache items
$cache->set('key1', 'value1');
$cache->set('key2', [1, 2, 3], 60); // with TTL of 60 seconds

// Get cache items
$value1 = $cache->get('key1');
$value2 = $cache->get('key2');

// Check if a cache item exists
$hasKey1 = $cache->has('key1');

// Delete cache items
$cache->delete('key1');

TODO

  • Lock functions so multiple threads will not overwrite values
  • Second release for PHP 8+

Contributing

Contributions are welcome! Please feel free to open an issue or submit a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.