Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/openclassrooms/cachebundle
Symfony3 Bundle for OpenClassrooms Cache
https://github.com/openclassrooms/cachebundle
cache openclassrooms php symfony symfony-bundle
Last synced: 29 days ago
JSON representation
Symfony3 Bundle for OpenClassrooms Cache
- Host: GitHub
- URL: https://github.com/openclassrooms/cachebundle
- Owner: OpenClassrooms
- License: mit
- Created: 2014-04-27T16:54:58.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2024-08-06T14:13:50.000Z (3 months ago)
- Last Synced: 2024-10-03T07:05:49.901Z (about 2 months ago)
- Topics: cache, openclassrooms, php, symfony, symfony-bundle
- Language: PHP
- Homepage:
- Size: 40 KB
- Stars: 0
- Watchers: 24
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/OpenClassrooms/CacheBundle.svg?branch=master)](https://travis-ci.org/OpenClassrooms/CacheBundle)
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/b04e23bf-8e36-4704-801e-bb29a7719ed3/mini.png)](https://insight.sensiolabs.com/projects/b04e23bf-8e36-4704-801e-bb29a7719ed3)
[![Coverage Status](https://coveralls.io/repos/OpenClassrooms/CacheBundle/badge.png?branch=master)](https://coveralls.io/r/OpenClassrooms/CacheBundle?branch=master)CacheBundle adds features to Doctrine Cache implementation
- Default lifetime
- Fetch with a namespace
- Save with a namespace
- Cache invalidation through namespace strategy
- CacheProvider BuilderSee [OpenClassrooms/Cache](https://github.com/OpenClassrooms/Cache) for more details.
## Installation
This bundle can be installed using composer:```composer require openclassrooms/cache-bundle```
or by adding the package to the composer.json file directly.```json
{
"require": {
"openclassrooms/cache-bundle": "*"
}
}
```After the package has been installed, add the bundle to the AppKernel.php file:
```php
// in AppKernel::registerBundles()
$bundles = array(
// ...
new OpenClassrooms\Bundle\CacheBundle\OpenClassroomsCacheBundle(),
// ...
);
```## Configuration
```yaml
open_classrooms_cache:
default_lifetime: 10 (optional, default = 0)
# Providers
# array
provider: array
# 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:
```php
$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:
```php
$cacheProvider = $container->get('openclassrooms.cache.cache_provider');
```The cache provider builder is available as ```openclassrooms.cache.cache_provider``` service:
```php
$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](https://github.com/OpenClassrooms/Cache) for more details.