Developed with love by KnpLabs Hire us for your project!
101

LiipDoctrineCacheBundle

by liip

Deprecated in favor of https://github.com/doctrine/DoctrineCacheBundle

DoctrineCacheBundle

This Bundle provides integration into Symfony2 with the Doctrine Common Cache layer.
It has been deprecated in favor of https://github.com/doctrine/DoctrineCacheBundle.

Installation

1. Add the bundle to your composer.json

"require": {
    ...
    "liip/doctrine-cache-bundle": "~1.0"
}

2. Install the bundle using composer

$ php composer.phar update liip/doctrine-cache-bundle

3. Add this bundle to your application's kernel:

<?php
// application/ApplicationKernel.php
public function registerBundles()
{
  return array(
      // ...
      new Liip\DoctrineCacheBundle\LiipDoctrineCacheBundle(),
      // ...
  );
}

Configuration

Simply configure any number of cache services:

# app/config.yml
liip_doctrine_cache:
    namespaces:
        # name of the service (aka liip_doctrine_cache.ns.foo)
        foo:
            # cache namespace is "ding", this is optional
            namespace: ding
            # cache type is "apc"
            type: apc
            # alias names of the service (liip_doctrine_cache.ns.foo_bar and liip_doctrine_cache.ns.foo_baz)
            alias: [foo_bar,foo_baz]
        # name of the service (aka liip_doctrine_cache.ns.lala) and namespace
        lala:
            # cache type is "file_system"
            type: file_system
            # optionally define a directory
            directory: /tmp/lala
            # single alias name (equivalent to `alias: [lala_bar]`)
            alias: lala_bar
        # name of the service (aka liip_doctrine_cache.ns.bar)
        bar:
            # cache namespace is "dong"
            namespace: dong
            # cache type is "memcached"
            type: memcached
            # name of a service of class Memcached that is fully configured (optional)
            id: my_memcached_service
            # port to use for memcache(d) (default is 11211)
            port: 11211
            # host to use for memcache(d) (default is localhost)
            host: localhost

Default values for the services are defined in the compiler pass:
https://github.com/liip/LiipDoctrineCacheBundle/blob/master/DependencyInjection/Compiler/ServiceCreationCompilerPass.php

Usage

Simply use liip_doctrine_cache.ns.[your_name] in dependency injection config files or using $container->get('liip_doctrine_cache.ns.[your_name]') in your code.

Custom cache types

Simply define a new type by defining a service named liip_doctrine_cache.[type name].
Note the service needs to implement Doctrine\Common\Cache\Cache interface.

Development mode

In development mode you do not want to cache things over more than one request. An easy
solution for this is to use the array cache in the dev environment.

#config.yml
liip_doctrine_cache:
    namespaces:
        presta_sitemap:
            type: file_system

# config_dev.yml
liip_doctrine_cache:
    namespaces:
        presta_sitemap:
            type: array

The array cache will be lost after each request, so effectively only cache if you access
the same data within one single request.

Copyright (c) 2011 Liip

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
liip_doctrine_cache:
namespaces:

# Prototype
name:
namespace: ~
type: ~ # Required
host: ~
port: ~
timeout: ~
id: ~
directory: ~
extension: ~
alias: []
  • Merge pull request #23 from c33s/master
    By lsmith77, 2 years ago
  • better visualization of the deprecated status
    By c33s, 2 years ago
  • added deprecation notice
    By lsmith77, 3 years ago
  • Merge pull request #21 from zibok/AddDeleteAllBatch
    By lsmith77, 3 years ago
  • Add a batch command allowing to invalidate a whole namespace
    By Vincent Lepot, 3 years ago
  • Merge pull request #19 from adrienbrault/patch-1
    By lsmith77, 3 years ago
  • Don't recommend to use dev-master
    By adrienbrault, 3 years ago
  • Merge pull request #17 from KingCrunch/alias
    By lsmith77, 3 years ago
  • Some docs for adapter-alias
    By KingCrunch, 3 years ago
  • Add ability to add alias to existing cache adapter configurations
    By KingCrunch, 3 years ago
  • Merge pull request #14 from maxromanovsky/redis
    By lsmith77, 3 years ago
  • Merge pull request #16 from robertfausk/master
    By lsmith77, 3 years ago
  • add ability to set timeout when instantiating memcache server
    By robertfausk, 3 years ago
  • Added Redis support
    By maxromanovsky, 3 years ago
  • add a note about default values
    By lsmith77, 4 years ago
  • Merge pull request #12 from robertfausk/patch-1
    By lsmith77, 4 years ago
  • added support to memcache for UNIX domain sockets
    By robertfausk, 4 years ago
  • Merge pull request #11 from jrobeson/patch-1
    By lsmith77, 4 years ago
  • remove symfony 2.0 installation instructions
    By jrobeson, 4 years ago
  • Merge pull request #10 from jenkoian/add-branch-alias
    By lsmith77, 4 years ago
  • Provide branch alias
    By jenkoian, 4 years ago
  • Update README.md
    By dbu, 4 years ago
  • Merge pull request #7 from benjamindulau/env_namespace
    By lsmith77, 4 years ago
  • Updated compiler pass to always use the config key in service IDs. This allows for instance to set different namespaces depending on the environment; useful when using different environments on the same server.
    By benjamindulau, 4 years ago
  • tweaked docs
    By roderik, 4 years ago
  • case sensitivity oops
    By lsmith77, 4 years ago
  • more sane default cache dir for file system cache
    By lsmith77, 4 years ago
  • Merge pull request #6 from ConneXNL/master
    By lsmith77, 4 years ago
  • Update DependencyInjection/Compiler/ServiceCreationCompilerPass.php
    By ConneXNL, 4 years ago
  • Update Resources/config/services.xml
    By ConneXNL, 4 years ago