Code Monkey home page Code Monkey logo

incache's Introduction

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.

incache's People

Contributors

pavel-u avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.