GithubHelp home page GithubHelp logo

arnaud-23 / cachebundle Goto Github PK

View Code? Open in Web Editor NEW

This project forked from openclassrooms/cachebundle

0.0 2.0 0.0 122 KB

Symfony2 Bundle for OpenClassrooms Cache

License: MIT License

PHP 100.00%

cachebundle's Introduction

Build Status SensioLabsInsight Coverage Status

CacheBundle adds features to Doctrine Cache implementation

  • Default lifetime
  • Fetch with a namespace
  • Save with a namespace
  • Cache invalidation through namespace strategy
  • CacheProvider Builder

See OpenClassrooms/Cache for more details.

Installation

This bundle can be installed using composer:

composer require jms/serializer-bundle or by adding the package to the composer.json file directly.

{
    "require": {
        "openclassrooms/cache-bundle": "*"
    }
}

After the package has been installed, add the bundle to the AppKernel.php file:

// in AppKernel::registerBundles()
$bundles = array(
    // ...
    new OpenClassrooms\Bundle\CacheBundle\OpenClassroomsCacheBundle(),
    // ...
);

Configuration

open_classrooms_cache:
    default_lifetime: 10    (optional, default = 0)
# Providers
    # array
    provider: array
    # memcache
    provider:
        memcache:
            host: localhost
            port: 11211     (optional, default = 11211)
            timeout: 0      (optional, default = 0)
    # memcached
    provider:
        memcached:
            host: localhost
            port: 11211     (optional, default = 11211)
    # redis            
    provider:
        redis:
            host: localhost
            port: 6379      (optional, default = 6379)
            timeout: 0.0    (optional, default = 0.0)

Usage

The configured cache is available as openclassrooms.cache.cache service:

$cache = $container->get('openclassrooms.cache.cache');

$cache->fetch($id);
$cache->fetchWithNamespace($id, $namespaceId);
$cache->save($id, $data);
$cache->saveWithNamespace($id, $data, $namespaceId);
$cache->invalidate($namespaceId);

The configured cache provider is available as openclassrooms.cache.cache_provider service:

$cacheProvider = $container->get('openclassrooms.cache.cache_provider');

The cache provider builder is available as openclassrooms.cache.cache_provider service:

$builder = $container->get('openclassrooms.cache.cache_provider_builder');

// Redis
$cacheProvider = $builder
    ->create(CacheProviderType::REDIS)
    ->withHost('127.0.0.1')
    ->withPort(6379) // Default 6379
    ->withTimeout(0.0) // Default 0.0
    ->build();

See OpenClassrooms/Cache for more details.

cachebundle's People

Contributors

romainkuzniak avatar arnaud-23 avatar

Watchers

James Cloos 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.