ZP-230 Create SQL state provider. Released under the Affero GNU General Public...

ZP-230 Create SQL state provider. Released under the Affero GNU General Public License (AGPL) version 3.
parent 6a1891a9
create table zpush_settings (key_name varchar(50) not null, key_value varchar(50) not null, created_at datetime not null, updated_at datetime not null, primary key (key_name));
create table zpush_users (username varchar(50) not null, device_id varchar(50) not null, created_at datetime not null, updated_at datetime not null, primary key (username, device_id));
create table zpush_states (id_state integer auto_increment, device_id varchar(50) not null, uuid varchar(50), state_type varchar(50), counter integer, state_data mediumblob,
created_at datetime not null, updated_at datetime not null, primary key (id_state));
create unique index idx_zpush_states_unique on zpush_states (device_id, uuid, state_type, counter);
-- This is optional, and will require extra configuration in your mysql
-- http://www.mysqlperformanceblog.com/2012/05/30/data-compression-in-innodb-for-text-and-blob-fields/
alter table zpush_states engine=InnoDB row_format=compressed key_block_size=16;
...@@ -70,12 +70,36 @@ ...@@ -70,12 +70,36 @@
*/ */
define('USE_FULLEMAIL_FOR_LOGIN', false); define('USE_FULLEMAIL_FOR_LOGIN', false);
/**********************************************************************************
* Select StateMachine mechanism
*
* FILE => FileStateMachine, default
* SQL => SqlStateMachine
*/
define('STATE_MACHINE', 'FILE');
/********************************************************************************** /**********************************************************************************
* Default FileStateMachine settings * Default FileStateMachine settings
*/ */
define('STATE_DIR', '/var/lib/z-push/'); define('STATE_DIR', '/var/lib/z-push/');
/**********************************************************************************
* Optional SqlStateMachine settings
*
* DSN: formatted PDO connection string
* mysql:host=xxx;port=xxx;dbname=xxx
* DON'T FORGET TO INSTALL THE PHP-DRIVER PACKAGE!!!
* USER: username to DB
* PASSWORD: password to DB
* OPTIONS: array with options needed
*/
define('STATE_SQL_DSN', '');
define('STATE_SQL_USER', '');
define('STATE_SQL_PASSWORD', '');
define('STATE_SQL_OPTIONS', serialize(array(PDO::ATTR_PERSISTENT => true)));
/********************************************************************************** /**********************************************************************************
* Logging settings * Logging settings
* Possible LOGLEVEL and LOGUSERLEVEL values are: * Possible LOGLEVEL and LOGUSERLEVEL values are:
......
...@@ -364,8 +364,14 @@ class ZPush { ...@@ -364,8 +364,14 @@ class ZPush {
} }
else { else {
// Initialize the default StateMachine // Initialize the default StateMachine
include_once('lib/default/filestatemachine.php'); if (defined('STATE_MACHINE') && STATE_MACHINE == 'SQL') {
ZPush::$stateMachine = new FileStateMachine(); include_once('lib/default/sqlstatemachine.php');
ZPush::$stateMachine = new SqlStateMachine();
}
else {
include_once('lib/default/filestatemachine.php');
ZPush::$stateMachine = new FileStateMachine();
}
} }
if (ZPush::$stateMachine->GetStateVersion() !== ZPush::GetLatestStateVersion()) { if (ZPush::$stateMachine->GetStateVersion() !== ZPush::GetLatestStateVersion()) {
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment