Git Product home page Git Product logo

doctrine-cache-detector's Introduction

Doctrine Cache Dectector

Detects all available cache layers using Doctrine\Common\Cache

Also contains some performance data to select the best available Cache system.

This can be useful for varying development environments.

Usage

List all supported caches

<?php
use Lavoiesl\Doctrine\CacheDetector\CacheDetector;

$cache_detector = new CacheDetector;
$detectors = $cache_detector->getSupportedDetectors();

/**
 * [Apc, Filesystem, PhpFile, etc.]
 */
print_r(array_keys($detectors));

// Doctrine\Common\Cache\ApcCache
$cache = $detectors['Apc']->getCache();
?>

Provide connection options

Provide options for the detector, see each detector for details.

<?php
$cache_detector->setConfig('Redis', array('port' => 1234));

// or

$cache_detector->setConfigs(array(
    'Redis' => array('port' => 1234),
));
?>

Select best cache system

This will automatically select the most performant cache system with a requirement on the persistance level.

On a local machine, ArrayCache will suffice. On a production environment, you may want to require a distributed one.

<?php
use Lavoiesl\Doctrine\CacheDetector\Detector\AbstractDetector;

$array_cache    = $cache_detector->selectBest(AbstractDetector::PERSISTANCE_REQUEST)->getCache();
$apc_cache      = $cache_detector->selectBest(AbstractDetector::PERSISTANCE_LOCAL_SERVICE)->getCache();
$file_cache     = $cache_detector->selectBest(AbstractDetector::PERSISTANCE_LOCAL_PERMANENT)->getCache();
$memcache_cache = $cache_detector->selectBest(AbstractDetector::PERSISTANCE_DISTRIBUTED)->getCache();
?>

Todo

  • Add support for MongoDB, Couchbase and Riak.
  • Add better data for performance

Author

doctrine-cache-detector's People

Contributors

lavoiesl avatar

Watchers

 avatar  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.