8000 GitHub - pavel-u/InCache
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

pavel-u/InCache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

InCache

InCache is a simple tool which will going to represent cache as a new level of abstraction via DSL.

Installing

Composer

The fastest way to install InCache in your project is using Composer.

  1. Install Composer:

    curl -s https://getcomposer.org/installer | php
    
  2. Add InCache as a dependency to your composer.json file:

    {
        "require": {
            "pavel-u/in-cache": "dev-master"
        }
    }

Currently project is in the development state. So, "dev-master" version should be used.

  1. Install InCache:

    php composer.phar install
    

Usage

Configure Interceptor

Initialize InCache interceptor:

$interceptor = new \InCache\Interceptor;

Set Root path:

$interceptor->setRootPath(__DIR__)

Set path to the config file:

$interceptor->setConfigPath(realpath(__DIR__ . DIRECTORY_SEPARATOR . 'etc/cache.xml'))

Start to intercept methods calls:

$interceptor->listen()

Generate proxy classess. First parameter is used to process force code generation:

$interceptor->generate(true);

Add config file

Here is an example of config file

<?xml version="1.0" encoding="UTF-8" ?>
<cache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="../vendor/pavel-u/in-cache/src/InCache/cache.xsd">
    <config>
        <argument name="cacheDir" value="/var/www/test/_cache"/>
    </config>
    <types>
        <type name="file" driver="\Stash\Driver\FileSystem" pool="\Stash\Pool" />
    </types>
    <evict
        class="Vendor\TestClass"
        method="testEvictMethod"
        key="someCacheIdentifier"
        type="file"
    />
    <caching
        class="Vendor\TestClass"
        method="testMethod"
        ttl="5"
        type="file"
        key="someCacheIdentifier"
    />
    <caching
        class="Vendor\TestClass"
        method="testMethod2"
        ttl="5"
        type="file"
    />
</cache>

Cache Driver MUST implements Stash\Interfaces\DriverInterface interface. Cache Pool MUST implements Stash\Interfaces\PoolInterface

Also, you could always check XSD file which will provide you more datails about DSL.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0