Skip to content
PHP
Latest commit bed7bd2 Dec 20, 2013 @philippe-levan philippe-levan fixes for insight
Failed to load latest commit information.
DependencyInjection
Entity
Model fixes for insight Dec 20, 2013
Resources/config
Tests
.gitignore basic unit tests Sep 9, 2013
.travis.yml travis-ci integration Sep 9, 2013
KitpagesSimpleCacheBundle.php
LICENSE add a license file (BSD style) Jun 24, 2011
README.md doc and fix in composer.json May 24, 2012
composer.json
phpunit.xml.dist

README.md

KitpagesSimpleCacheBundle

Very simple cache system for symfony2. The cache data are saved in one table in database.

author : Philippe Le Van (twitter : @plv) http://www.kitpages.fr/fr/cms/102/kitpagessimplecachebundle

Installation

hum... as usual...

put the code in vendors/Kitpages/SimpleCacheBundle

add vendors/ in the app/autoload.php

add the new Bundle in app/appKernel.php

You need to create a table in the database :

CREATE TABLE `simple_cache_backend` (
  `id` varchar(255) NOT NULL,
  `data` longtext COMMENT '(DC2Type:array)',
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `expired_at` datetime default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

(or you can use php app/console doctrine:schema:update)

Users Guide

1/ record & retrieve into/from the cache

$cacheManager = $this->get('kitpages.simple_cache');
$html = $cacheManager->get(
    'my-cache-uniq-id-12',
    function() {
        $output = "hello world";
        sleep (3);
        return $output;
    }
);

2/ clear the cache

$cacheManager = $this->get('kitpages.simple_cache');
$cacheManager->clear('my-cache-uniq-id-12');

3/ a more complex example : arguments given to the callback and expiration

$html = $cacheManager->get(
    'my-cache-uniq-id-12',
    function($arg1, $arg2) {
        $output = "hello world";
        sleep (3);
        return $output;
    },
    array(12, 34),
    $myExpirationTimeInSeconds
);

4/ multiple delete in the cache

$cacheManager = $this->get('kitpages.simple_cache');
$cacheManager->clear('my-cache-%');
// remove all the entries in the cache beginning by "my-cache-"
Something went wrong with that request. Please try again.