PHPackages                             aneo/cache - 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. aneo/cache

ActiveLibrary[Caching](/categories/caching)

aneo/cache
==========

php cache library

v1.0.0(10y ago)0571MITPHPPHP &gt;=5.3.0

Since Mar 12Pushed 10y ago1 watchersCompare

[ Source](https://github.com/ouonet/aneoCache)[ Packagist](https://packagist.org/packages/aneo/cache)[ Docs](https://github.com/ouonet/aneoCache)[ RSS](/packages/aneo-cache/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (2)Used By (1)

aneo/cache
==========

[](#aneocache)

aneo/cache is a php cache library, which keeps content fresh,via updating content upon source is changed.

Although there are a lot of php cache libraries, I still have not found(no time to try one by one) what I need. For example, doctrine/cache is very famouse one,it will keep data until expiration.if source is changed before expiration, it won't refresh it.Another inconvenience is :doctrine/cache always use php serialize/unserialize to save/load data, low performance.

Requirment
==========

[](#requirment)

We want to save heavy-time-consuming result data for saving time to get this result next time,we need a cache library to do：

1. client can save result
2. client can get result
3. cache should refresh content if source is changed.
4. client can decide where to save,eg. disk ,memcache ,apc....
5. Serializing result is not cache's responsibility, it's client's.

Cache strategy
==============

[](#cache-strategy)

Strategy is quit simple,upon client require data:

1. if data is in memory(an array),return it
2. else if data is persisted and source is not modified since last time, load it to memory ,and return it
3. otherwise ask source provider to get data,persist it ,then return it.

Feature#
========

[](#feature)

1. refresh content upon source is changed
2. can save data to file, memcache.

Usage
=====

[](#usage)

\##Install## composer require aneo/cache

Guide/Example
-------------

[](#guideexample)

**prepare CacheDataProvider**

To use cache,should provide a CacheDataProvider,to generate data and id,and determinate validation.

```
use aneo\cache\CacheDataProvider;

Class HtmlTemplate implements  CacheDataProvider{
    function get($name)
    {
       return $this->compile($name);
    }

    function isModifiedSince($name, $time)
    {
       return filemtime($name)>$time;
    }

    function cacheId($name)
    {
       return 'htmlTemplate\\'.$name.'.php';
    }

    /**
     * @param string $name
     * @return string
     */
    function compile($name){
        //.............
    }
}

```

After prepared cacheDataProvider, we can use cache:

**save to file**

```
$cache=new CacheByFile('path/to/cache');
$dataProvider= new HtmlTemplate();//a class implements interface aneo/cache/CacheDataProvider
$name= 'foo.html';
$result=$cache->get($name,$dataProvider);

```

**save to memcache**

```
$memcache_obj = new Memcache;
$memcache_obj->connect('127.0.0.1', 11211);
$cache = new CacheByMemcache($memcache_obj);
$dataProvider= new HtmlTemplate();//a class implements interface aneo/cache/CacheDataProvider
$name= 'foo.html';
$result=$cache->get($name,$dataProvider);

```

**serialize/unserialze/initialize**

In mostly case , data is not string. to persist it , we need translate it to string. How to translate it to string ,it depends on dataProvider, eg.,we can use serialze,json\_encode, var\_export... . And after we reload it , we need translate it to correct object,eg. we can use unserialize, json\_decode,eval... . Further on, we need re-initial it . So, dataProvider should implement three optional function :

1. function encode($data);
2. function decode($data);
3. function initial($data);

Cache will auto detect these functions , and call them.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity58

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

3717d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c76e371bdf165549056036f6c552188b7691407db4e8e35e893c213d14a8e10b?d=identicon)[ouonet](/maintainers/ouonet)

---

Top Contributors

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

---

Tags

cachecaching

### Embed Badge

![Health badge](/badges/aneo-cache/health.svg)

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

###  Alternatives

[psr/simple-cache

Common interfaces for simple caching

8.1k727.3M2.1k](/packages/psr-simple-cache)[react/cache

Async, Promise-based cache interface for ReactPHP

444112.4M40](/packages/react-cache)[tedivm/stash

The place to keep your cache.

9824.8M124](/packages/tedivm-stash)[spatie/blink

Cache that expires in the blink of an eye

1685.0M8](/packages/spatie-blink)[gregwar/cache

A lightweight file-system cache system

1084.5M22](/packages/gregwar-cache)[putyourlightson/craft-blitz

Intelligent static page caching for creating lightning-fast sites.

153471.5k29](/packages/putyourlightson-craft-blitz)

PHPackages © 2026

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