2017 © Pedro Peláez
 

library memcache-service-provider

Memcache integration for Silex.

image

kuikui/memcache-service-provider

Memcache integration for Silex.

  • Saturday, May 16, 2015
  • by KuiKui
  • Repository
  • 3 Watchers
  • 13 Stars
  • 16,986 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 9 Forks
  • 2 Open issues
  • 5 Versions
  • 3 % Grown

The README.md

Memcache service provider for Silex 2.x

Build Status Total Downloads, (*1)

It provides access to : * a simple Memcache wrapper with very simple API for standard use, * or your own Memcache wrapper with $app injection for custom use, * or a genuine Memcache(d) object for advanced use., (*2)

Installation

Create a composer.json in your projects root-directory :, (*3)

{
    "require": {
        "kuikui/memcache-service-provider": "~2.0"
    }
}

and run :, (*4)

$ curl -sS http://getcomposer.org/installer | php
$ php composer.phar install

Registering

$app->register(new KuiKui\MemcacheServiceProvider\ServiceProvider());

Example

$app->register(new KuiKui\MemcacheServiceProvider\ServiceProvider());

// Simple use
$app['memcache']->set('key', 'value');
$value = $app['memcache']->get('key');
$app['memcache']->delete('key');

// Advanced use : use \Closure to generate default value and save it during a retrieve process
$value = $app['memcache']->get('key', function() use ($app) {
    return $app['some_other_service']->getData();
});

Options

After registration, you can customize the service with these options :, (*5)

Connections

Allows you to set up one or more Memcache connections.
Each connection should be defined as follows array('ip_address', port)., (*6)

$app['memcache.connections'] = array(
    array('127.0.0.1', 11211),
    array('10.0.1.118', 12345)
; // default: array('127.0.0.1', 11211)

Class

Allows you to choose between the two PHP Memcache libraries : \Memcache or \Memcached., (*7)

$app['memcache.class'] = '\Memcached'; // default: '\Memcache'

Wrapper

  • By default, you access to an instance of KuiKui\MemcacheServiceProvider\SimpleWrapper.
  • For custom needs, you can use your own wrapper :
$app['memcache.wrapper'] = '\My\Custom\Wrapper';
  • Or you can have direct acces to Memcache(d) object :
$app['memcache.wrapper'] = false;

Duration

If you use SimpleWrapper, you can configure the default duration of cached data (in seconds):, (*8)

$app['memcache.default_duration'] = 60; // default: 0 (no limit)

Running the tests

The development environment is provided by Vagrant and the Xotelia box., (*9)

$ cp Vagrantfile.dist Vagrantfile
$ vagrant up
$ vagrant ssh
$ cd /vagrant
$ composer install
$ ./vendor/bin/atoum

Dependencies

PHP 5.5+, (*10)

MemcacheServiceProvider needs one of these PHP modules to be installed : * memcache * memcached, (*11)

Credits

Deeply inspired by MemcacheServiceProvider from Rafał Filipek.
Tested with atoum., (*12)

License

The MemcacheServiceProvider is licensed under the MIT license., (*13)

The Versions

16/05 2015

dev-master

9999999-dev https://github.com/KuiKui/MemcacheServiceProvider

Memcache integration for Silex.

  Sources   Download

MIT

The Development Requires

silex memcache

16/05 2015

v2.0.0

2.0.0.0 https://github.com/KuiKui/MemcacheServiceProvider

Memcache integration for Silex.

  Sources   Download

MIT

The Development Requires

silex memcache

16/05 2015

1.x-dev

1.9999999.9999999.9999999-dev https://github.com/KuiKui/MemcacheServiceProvider

Memcache integration for Silex.

  Sources   Download

MIT

The Development Requires

silex memcache

06/03 2015

v1.1.0

1.1.0.0 https://github.com/KuiKui/MemcacheServiceProvider

Memcache integration for Silex.

  Sources   Download

MIT

The Development Requires

silex memcache

22/08 2014

v1.0.0

1.0.0.0 https://github.com/KuiKui/MemcacheServiceProvider

Memcache integration for Silex.

  Sources   Download

MIT

The Development Requires

silex memcache