Git Product home page Git Product logo

cachebundle's Introduction

winzouCacheBundle

What's that?

winzouCacheBundle provides a simple cache management. Now you can use a cache system without reinventing it. It supports Apc, XCache, File, ZendData and Array.

Usage

In your controller:

$cache = $this->get('winzou_cache.apc');
// or
$cache = $this->get('winzou_cache.file');
// or
$cache = $this->get('winzou_cache.memcache');
// or
$cache = $this->get('winzou_cache.array');
// or
$cache = $this->get('winzou_cache.xcache');
// or
$cache = $this->get('winzou_cache.zenddata');
// or
$cache = $this->get('winzou_cache'); // in that case, it will use the default driver defined in config.yml, see below

$cache->save('bar', array('foo', 'bar'));

if ($cache->contains('bar')) {
    $bar = $cache->fetch('bar');
}

See Cache\AbstractCache for all the available methods.

Configuration

When using FileCache, if you don't want to store your cache files in CACHE_DIR/winzou_cache (default value), then define the absolute path in your config.yml:

winzou_cache:
    options:
        cache_dir: %kernel.cache_dir%/MyAppCache
# or    cache_dir: /tmp/MyAppCache/%kernel.environment%

If you want to define in only one place the driver you want to use, you will like the default_driver option:

winzou_cache:
    options:
        default_driver: apc # default is "file"

# and then $cache = $this->get('winzou_cache')

You can now access the FileCache with the winzou_cache service. And if you want to change the driver, you have to modify only one value in your config.yml.

Raw access

You can overwrite any option just by using the factory service. See these two very similar methods:

$factory = $this->get('winzou_cache.factory');
$cache = $factory->get('file', array('cache_dir' => '/tmp/cache'));

Or by defining your own service:

your_cache:
    factory_service: winzou_cache.factory
    factory_method:  get
    class:           %winzou_cache.driver.file%
    arguments:
        - file
        - {'cache_dir': /tmp/cache }

# and then $cache = $this->get('your_cache')

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.