PHPackages                             zoopcommerce/juggernaut - 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. zoopcommerce/juggernaut

ActiveLibrary[Caching](/categories/caching)

zoopcommerce/juggernaut
=======================

A caching module for PHP that includes adapters for File System, APC and Memcached. It also includes a number of helper classes for DB caching and full page cache

1.2.0(12y ago)61.4k[2 issues](https://github.com/zoopcommerce/juggernaut/issues)1MITPHPPHP &gt;=5.3.0

Since Jul 10Pushed 12y ago2 watchersCompare

[ Source](https://github.com/zoopcommerce/juggernaut)[ Packagist](https://packagist.org/packages/zoopcommerce/juggernaut)[ Docs](http://github.com/zoopcommerce/juggernaut)[ RSS](/packages/zoopcommerce-juggernaut/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependenciesVersions (7)Used By (1)

\#Juggernaut

Introduction
------------

[](#introduction)

Juggernaut is a super fast PHP cache. It has a number of storage adapters and a few simple helpers to get you up and caching quickly.

One of the best aspects of this module is that it provides **flood protection** both on the initial cache creation - *by queuing subsequent requests* - but also on re-caching - *by serving old cache for subsequent requests until the new cache has been re-created*.

These two features allow Juggernaut to be at least **100%** faster than the [Zend Framework 2 cache adapters](http://framework.zend.com/manual/2.2/en/modules/zend.cache.storage.adapter.html) in normal use, and up to **270%** faster on highly concurrent applications.

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

[](#installation)

Install the module using Composer into your application's vendor directory. Add the following line to your `composer.json`.

```
{
    "require": {
        "zoopcommerce/juggernaut": "dev-master"
    }
}
```

Usage
-----

[](#usage)

You can use Juggernaut by directly instantiating a storage adapter and calling set/get.

### Key-Value-Pair Caching Using Storage Adapters

[](#key-value-pair-caching-using-storage-adapters)

#### File System

[](#file-system)

```
// you should always store the cache below the web root for security!!
$cacheDirectory = __DIR__ . '../cache';

$cache = new Zoop\Juggernaut\Adapter\FileSystem($cacheDirectory);

$key = 'yourUniqueKey';

$data = $cache->getItem($key, $success);

// check if cache hit/miss
if ($success === false) {
  // cache missed so now we have to execute
	// some query that takes a long time
	for($i=0;$isetItem($key, $data);
    echo $data;
} else {
	// cache hit!
    echo $data;
}
```

#### MongoDB

[](#mongodb)

```
$mongo = new MongoClient('mongodb://username:password@localhost:27017');
$collection = $mongo->selectCollection('Cache');

$cache = new Zoop\Juggernaut\Adapter\MongoDB($collection);

$key = 'yourUniqueKey';

$data = $cache->getItem($key, $success);

// check if cache hit/miss
if ($success === false) {
	// cache missed so now we have to execute
	// some query that takes a long time
	for($i=0;$isetItem($key, $data);
    echo $data;
} else {
	// cache hit!
    echo $data;
}
```

#### Memcached

[](#memcached)

```
//coming soon
```

#### MySQL

[](#mysql)

```
//coming soon
```

### Helpers

[](#helpers)

There are a few helpers that will expidite the usage of Juggernaut.

#### Full Page

[](#full-page)

As the name suggests, the "Full Page" helper will store the rendered page directly to cache. This results in blindingly fast page loads.

To use this script just place the following at the top of your pages.

```
$pageTtl = 600; //10 mins
$cacheDirectory = __DIR__ . '../cache';

$adapter = new Zoop\Juggernaut\Adapter\FileSystem($cacheDirectory);

$pageCache = new Zoop\Juggernaut\Helper\FullPage($adapter, $pageTtl);
$pageCache->start();
```

You can use any of the provided adapters to store the full page cache. eg.

```
$pageTtl = 600; //10 mins
$database='MyMongoDb';
$username='mymongouser';
$password='mymongopass';

$adapter = new Zoop\Juggernaut\Adapter\MongoDB($database, $username, $password);

$pageCache = new Zoop\Juggernaut\Helper\FullPage($adapter, $pageTtl);
$pageCache->start();
```

There's no need to manually save the rendered page to cache as the script will automatically flush the page output to the cache adapter once the script exits.

#### Database

[](#database)

#### MySQLi

[](#mysqli)

You can use the mysqli helper to automatically cache your sql queries.

```
$cacheDirectory = __DIR__ . '../cache';
$adapter = new Zoop\Juggernaut\Adapter\FileSystem($cacheDirectory);

$db = new Zoop\Juggernaut\Helper\Database\Mysqli($cache);
$db->connect($host, $username, $passwd, $database);

$q="SELECT COUNT(`pageviews`) as 'pageviews' FROM `analytics` GROUP BY `date`";
$r = $db->query($q, 600); //second arg is ttl
if($r!==false) {
	$pageviews = $db->fetchRow($q)['pageviews'];
}
```

As you can see you don't have to worry if the cache exists or not as the helper does all the heavy lifting.

Coming soon
-----------

[](#coming-soon)

- Unit tests
- Working examples
- MySQL adapter
- Memcached adapter
- MongoDB helper

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity62

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

Total

6

Last Release

4450d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1498361?v=4)[Zoop](/maintainers/zoopcommerce)[@zoopcommerce](https://github.com/zoopcommerce)

---

Top Contributors

[![superdweebie](https://avatars.githubusercontent.com/u/1670364?v=4)](https://github.com/superdweebie "superdweebie (5 commits)")

---

Tags

phpcaching

### Embed Badge

![Health badge](/badges/zoopcommerce-juggernaut/health.svg)

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

###  Alternatives

[voku/simple-cache

Simple Cache library

332.7M10](/packages/voku-simple-cache)[alekseykorzun/memcached-wrapper-php

Optimized PHP 5 wrapper for Memcached extension that supports dog-piling, igbinary and local storage

2988.9k1](/packages/alekseykorzun-memcached-wrapper-php)[rapidwebltd/rw-file-cache

RW File Cache is a PHP File-based Caching Library. Its syntax is designed to closely resemble the PHP memcache extension.

15195.9k7](/packages/rapidwebltd-rw-file-cache)[jord-jd/do-file-cache

DO File Cache is a PHP File-based Caching Library. Its syntax is designed to closely resemble the PHP memcache extension.

1510.3k4](/packages/jord-jd-do-file-cache)

PHPackages © 2026

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