PHPackages                             storefrontbvba/zend-cache-redis - 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. storefrontbvba/zend-cache-redis

ActiveLibrary[Caching](/categories/caching)

storefrontbvba/zend-cache-redis
===============================

Zend\_Cache backend using Redis with full support for tags, but without the need for Magento.

v1.0.0(6y ago)121BSD-3-ClausePHP

Since Nov 6Pushed 6y ago2 watchersCompare

[ Source](https://github.com/storefront-bvba/zend-cache-redis)[ Packagist](https://packagist.org/packages/storefrontbvba/zend-cache-redis)[ Docs](https://github.com/storefront-bvba/Cm_Cache_Backend_Redis)[ RSS](/packages/storefrontbvba-zend-cache-redis/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (2)Versions (2)Used By (0)

Zend\_Cache backend using Redis with full support for tags
==========================================================

[](#zend_cache-backend-using-redis-with-full-support-for-tags)

This Zend\_Cache backend allows you to use a Redis server as a central cache storage. Tags are fully supported without the use of TwoLevels cache so this backend is great for use on a single machine or in a cluster. Works with any Zend Framework project!

FEATURES
--------

[](#features)

- Uses the [phpredis PECL extension](https://github.com/nicolasff/phpredis) for best performance (requires **master** branch or tagged version newer than Aug 19 2011).
- Falls back to standalone PHP if phpredis isn't available using the [Credis](https://github.com/colinmollenhour/credis) library.
- Tagging is fully supported, implemented using the Redis "set" and "hash" datatypes for efficient tag management.
- Key expiration is handled automatically by Redis.
- Supports unix socket connection for even better performance on a single machine.
- Supports configurable compression for memory savings. Can choose between gzip, lzf and snappy and can change configuration without flushing cache.
- Uses transactions to prevent race conditions between saves, cleans or removes causing unexpected results.
- Supports a configurable "auto expiry lifetime" which, if set, will be used as the TTL when the key otherwise wouldn't expire.
- **Unit tested!**

High Availability and Load Balancing Support
--------------------------------------------

[](#high-availability-and-load-balancing-support)

There are two supported methods of achieving High Availability and Load Balancing with Cm\_Cache\_Backend\_Redis.

### Redis Sentinel

[](#redis-sentinel)

You may achieve high availability and load balancing using [Redis Sentinel](http://redis.io/topics/sentinel). To enable use of Redis Sentinel the `server`specified should be a comma-separated list of Sentinel servers and the `sentinel_master` option should be specified to indicate the name of the sentinel master set (e.g. 'mymaster'). If using `sentinel_master` you may also specify `load_from_slaves` in which case a random slave will be chosen for performing reads in order to load balance across multiple Redis instances. Using the value '1' indicates to only load from slaves and '2' to include the master in the random read slave selection.

Example configuration:

```

      Cm_Cache_Backend_Redis

        tcp://10.0.0.1:26379,tcp://10.0.0.2:26379,tcp://10.0.0.3:26379
        0.5
        mymaster
        1
        1

```

### Load Balancer or Service Discovery

[](#load-balancer-or-service-discovery)

It is also possible to achieve high availability by using other methods where you can specify separate connection addresses for the master and slave(s). The `load_from_slave` option has been added for this purpose and this option does *not*connect to a Sentinel server as the example above, although you probably would benefit from still having a Sentinel setup purely for the easier replication and failover.

Examples would be to use a TCP load balancer (e.g. HAProxy) with separate ports for master and slaves, or a DNS-based system that uses service discovery health checks to expose master and slaves via different DNS names.

Example configuration:

```

      Cm_Cache_Backend_Redis

        tcp://redis-master:6379
        tcp://redis-slaves:6379
        0
        0.5

```

### Static Configuration

[](#static-configuration)

You may also statically specify the master and slave servers by passing either an array to `load_from_slave` or a string with multiple addresses separated by a comma.

```

      Cm_Cache_Backend_Redis

        tcp://redis-master:6379
        tcp://redis-slave1:6379,tcp://redis-slave2:6379
        0
        0.5

```

ElastiCache
-----------

[](#elasticache)

The following example configuration lets you use ElastiCache Redis (cluster mode disabled) where the writes are sent to the Primary node and reads are sent to the replicas. This lets you distribute the read traffic between the different nodes.

The instructions to find the primary and read replica endpoints are [here](http://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/Endpoints.html#Endpoints.Find.Redis).

```

      primary-endpoint.0001.euw1.cache.amazonaws.com
      6379
      0
      1

          replica-endpoint-1.jwbaun.0001.euw1.cache.amazonaws.com
          6379

          replica-endpoint-2.jwbaun.0001.euw1.cache.amazonaws.com
          6379

```

#### DEPRECATION NOTICE

[](#deprecation-notice)

Previously the ElastiCache config instructions suggested setting up a `` node but this functionality was flawed and is no longer supported. The config is still parsed and loaded for backwards-compatibility but chooses a random slave to read from rather than using md5 hash of the keys.

RELATED / TUNING
----------------

[](#related--tuning)

- The recommended "maxmemory-policy" is "volatile-lru". All tag metadata is non-volatile so it is recommended to use key expirations unless non-volatile keys are absolutely necessary so that tag data cannot get evicted. So, be sure that the "maxmemory" is high enough to accommodate all of the tag data and non-volatile data with enough room left for the volatile key data as well.
- Automatic cleaning is optional and not recommended since it is slow and uses lots of memory.
- Occasional (e.g. once a day) garbage collection is recommended if the entire cache is infrequently cleared and automatic cleaning is not enabled. The best solution is to run a cron job which does the garbage collection. (See "Example Garbage Collection Script" below.)
- Compression will have additional CPU overhead but may be worth it for memory savings and reduced traffic. For high-latency networks it may even improve performance.
    - gzip — Slowest but highest compression. Most likely you will not want to use above level 1 compression.
    - lzf — Fastest compress, fast decompress. Install: `sudo pecl install lzf`
    - snappy — Fastest decompress, fast compress. Download and install: [snappy](http://code.google.com/p/snappy/) and [php-snappy](http://code.google.com/p/php-snappy/)
- Monitor your redis cache statistics with my modified [munin plugin](https://gist.github.com/1177716).
- Enable persistent connections. Make sure that if you have multiple configurations connecting the persistent string is unique for each configuration so that "select" commands don't cause conflicts.
- Use the `stats.php` script to inspect your cache to find oversized or wasteful cache tags.

Release Notes
-------------

[](#release-notes)

- March 2017: Added support for Redis Sentinel and loading from slaves. Thanks @Xon for the help!
- Sometime in 2013: Ceased updating these release notes...
- November 19, 2012: Added read\_timeout option. (Feature only supported in standalone mode, will be supported by phpredis when pull request #260 is merged)
- October 29, 2012: Added support for persistent connections. (Thanks samm-git!)
- October 12, 2012: Improved memory usage and efficiency of garbage collection and updated recommendation.
- September 17, 2012: Added connect\_retries option (default: 1) to prevent errors from random connection failures.
- July 10, 2012: Added password authentication support.
- Mar 1, 2012: Using latest Credis\_Client which adds auto-reconnect for standalone mode.
- Feb 15, 2012: Changed from using separate keys for data, tags and mtime to a single hash per key.
- Nov 10, 2011: Changed from using phpredis and redisent to Credis (which wraps phpredis). Implemented pipelining.

```
@copyright  Copyright (c) 2012 Colin Mollenhour (http://colin.mollenhour.com)
This project is licensed under the "New BSD" license (see source).

```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

2376d ago

### Community

Maintainers

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

---

Top Contributors

[![woutersamaey](https://avatars.githubusercontent.com/u/71019?v=4)](https://github.com/woutersamaey "woutersamaey (1 commits)")

### Embed Badge

![Health badge](/badges/storefrontbvba-zend-cache-redis/health.svg)

```
[![Health](https://phpackages.com/badges/storefrontbvba-zend-cache-redis/health.svg)](https://phpackages.com/packages/storefrontbvba-zend-cache-redis)
```

###  Alternatives

[colinmollenhour/cache-backend-redis

Zend\_Cache backend using Redis with full support for tags.

38522.9M13](/packages/colinmollenhour-cache-backend-redis)[colinmollenhour/php-redis-session-abstract

A Redis-based session handler with optimistic locking

6325.6M14](/packages/colinmollenhour-php-redis-session-abstract)[resque/php-resque

Redis backed library for creating background jobs and processing them later. Based on resque for Ruby.

2371.8M7](/packages/resque-php-resque)[rhubarbgroup/redis-cache

A persistent object cache backend for WordPress powered by Redis. Supports Predis, PhpRedis, Relay, replication, sentinels, clustering and WP-CLI.

51795.3k1](/packages/rhubarbgroup-redis-cache)

PHPackages © 2026

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