necromant2005/tt-ssdb

SSDB cache adapter for ZF2

1.2.0 2016-06-11 00:51 UTC

This package is auto-updated.

Last update: 2024-10-29 05:04:41 UTC


README

Version 2.0.1 Created by Rostislav Mykhajliw

Build Status

Introduction

SSDB adapter with Master/Slave replication support

Features / Goals

  • Standard interface zf2 Zend\Cache\Storage\Adapter
  • Support master/slave replication
  • Support wigth for servers reads
  • Support failover

Installation

Main Setup

With composer

  1. Add this to your composer.json:
"require": {
    "necromant2005/tt-ssdb": "1.*",
}
  1. Now tell composer to download TweeSSDB by running the command:
$ php composer.phar update

Usage

Configuration with 1 master and 2 slaves, due to wieght configuration only 1/5 reads go to master all other 4/5 to slaves. Each slave receives 2/5 reads.

use TweeSSDB\Cache\Storage\Adapter;

$options = new SSDBOptions(array(
    array('host' => '127.0.0.1', 'port' => 8888, 'weight' => 1, 'type' => 'master'),
    array('host' => '127.0.0.2', 'port' => 8888, 'weight' => 2, 'type' => 'slave'),
    array('host' => '127.0.0.3', 'port' => 8888, 'weight' => 2, 'type' => 'slave'),
));
$adapter = new SSDB($options);

Also it's possible to use multi master write - in this case writes will be distributed within all master nodes (as weel as reads)

use TweeSSDB\Cache\Storage\Adapter;

$options = new SSDBOptions(array(
    array('host' => '127.0.0.1', 'port' => 8888, 'weight' => 1, 'type' => 'master'),
    array('host' => '127.0.0.2', 'port' => 8888, 'weight' => 1, 'type' => 'master'),
    array('host' => '127.0.0.3', 'port' => 8888, 'weight' => 1, 'type' => 'master'),
));
$adapter = new SSDB($options);