StormCache
An advanced library to extend and handle PECL-Memcached.
Loading...
Searching...
No Matches
Storm Cache

Build Status ![License](https://img.shields.io/badge/license-MIT-brightgreen.svg) PHP Version

Lightweight, robust wrapper around PECL-Memcached that adds pool management, optional encryption, and namespace-based expiration to simplify caching in PHP applications.

Author: David Carlos Manuelda (StormByte)


Key features

  • Multiple named pools to separate caches for different concerns.
  • Lazy instantiation of Memcached resources — safe to include even if PECL-Memcached is not installed (no servers configured = no active cache).
  • Optional encryption support for cache items.
  • Namespace support for bulk-expiration of related keys.
  • Small, simple API designed for minimal intrusion into existing code.

Requirements

  • PHP >= 5.0
  • PECL-Memcached (only required when you actually bind servers to pools)

Installation

If you manage dependencies with Composer, prefer installing a packaged release when available. Otherwise you can include the library directly from the lib/ folder:

See lib/StormCache.php for the main implementation and Usage.php for examples.

Quick Start

Example: minimal usage with the default pool.

<?php
require_once 'lib/StormCache.php';
$cache = StormCache::GetInstance();
// Add a server to the default pool (lazy-instantiates the Memcached resource)
$cache->AddPoolServer('127.0.0.1', 11211);
// Set and get a value
$cache->Set('my_key', ['foo' => 'bar'], null, 3600); // 1 hour
$cache->Get('my_key', $value);
var_dump($value);

Advanced: create and configure named pools, enable encryption, or bind items to namespaces. See lib/StormCache.php and the docs/ folder for full API documentation.

Namespaces

Namespaces allow grouping related keys so they can be expired together. Example:

$cache->Set('UserData:1', $data, 'UserNamespace:1', 86400);
$cache->ExpireNamespace('UserNamespace:1');

Exceptions and error handling

The library throws exceptions for misconfiguration (missing pools, encryption problems, etc.). Wrap Get/Set calls in try/catch when you need to handle those cases explicitly; otherwise you can catch Exception as a fallback and fall back to your primary data source.

Documentation

API documentation is available in the docs/ folder generated by Doxygen. Open docs/index.html in your browser for full class and member references.

Contributing

Contributions and bug reports are welcome. Please open issues or pull requests in the repository. Start by running examples in Usage.php and the included docs.

License

This project is licensed under the MIT License — see LICENSE.md for details.


For questions or support contact: Storm.nosp@m.Byte.nosp@m.@gmai.nosp@m.l.co.nosp@m.m