Doctrine\DBAL\Sharding\ShardManager
Sharding Manager gives access to APIs to implementing sharding on top of Doctrine\DBAL\Connection instances.
For simplicity and developer ease-of-use (and understanding) the sharding
API only covers single shard queries, no fan-out support. It is primarily
suited for multi-tenant applications.
The assumption about sharding here
is that a distribution value can be found that gives access to all the
necessary data for all use-cases. Switching between shards should be done with
caution, especially if lazy loading is implemented. Any query is always
executed against the last shard that was selected. If a query is created for
a shard Y but then a shard X is selected when its actually excecuted you
will hit the wrong shard.
- Author: Benjamin Eberlei <kontakt@beberlei.de>
Synopsis
interface ShardManager
{
- // methods
- public void selectGlobal()
- public void selectShard()
- public string getCurrentDistributionValue()
- public array getShards()
- public array queryAll()
Methods
public
- getCurrentDistributionValue() — Get the distribution value currently used for sharding.
- getShards() — Get information about the amount of shards and other details.
- queryAll() — Query all shards in undefined order and return the results appended to each other. Restore the previous distribution value after execution.
- selectGlobal() — Select global database with global data.
- selectShard() — SELECT queries after this statement will be issued against the selected shard.