Home

Awesome

About

This library can be helpful if you need to develop highload & stable data storage access layer. Unlike other data abstraction libraries Abstract Storage has a lot of caching, sharding, loggin & transactions emulation interfaces.

Features

Example

Initialization of keys sharding interface generated by server-weight index & stored staticaly in MySQL table with caching in Redis and requests loggin in /logs/data.log

$shard = new Storage_Shard_MySQL(
	new Storage_Shard_Keys_Provider_StoredKeys(
		new Storage_Shard_Keys_Generator_Weights(Storage_Shard_Keys_Generator_Weights::getWeightsFromMultiArray(Config::$MYSQL_SHARD_SERVERS)),
		new Storage_KeyValue_Cached(
			new Storage_KeyValue_MySQL(new Storage_MySQL(Config::BASE_MYSQL_HOST, Config::BASE_MYSQL_USER, Config::BASE_MYSQL_PASSWORD, Config::BASE_MYSQL_DB, $this->logger), 'users_servers', 'server_id', 'user_id'),
			new Storage_KeyValue_RedisPrefixed(
				new Storage_Redis(Config::REDIS_HOST), Config::DATA_NAMESPACE_ALIAS . ':users_servers:', 60 * 60 * 12,
				new Storage_Logger_File('/logs/data.log'),
			true
		),
		false,
		new Storage_Locker_Redis(new Storage_Redis(Config::REDIS_HOST), Config::DATA_NAMESPACE_ALIAS . ':lock:')
	),
	Config::$MYSQL_SHARD_SERVERS
));

Initialization sharded MySQL key-value storage

$storage = new Storage_KeyValue_Sharded(
	new Storage_Shard_Clone($shard, function(Storage_MySQL $connection) {
		return new Storage_KeyValue_MySQL($connection, 'users_sessions');
});

Recommended