Skip to content

Latest commit

 

History

History
47 lines (37 loc) · 2.08 KB

readme.md

File metadata and controls

47 lines (37 loc) · 2.08 KB

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

  • Databases connection intefaces for MySQL, Mongo, Redis
  • Data storages interfaces
  • Key-Value for MySQL, Mongo, Redis, Memcache, Redis, File, Cached, Sharded
  • Key-Object for MySQL, Mongo
  • Queue for Redis, MemcacheQ, Memory
  • Data storages requests loggers
  • Transactions with commit-rollback support
  • Data lockers for emulating transactions locks with auto unlock
  • Storages sharding interface with static & dynamic partitioning support

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