Download the PHP package aneo/cache without Composer

On this page you can find all versions of the php package aneo/cache. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package cache

aneo/cache

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

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

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

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

Usage

Install

composer require aneo/cache

Guide/Example

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.


All versions of cache with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package aneo/cache contains the following files

Loading the files please wait ...