v2: Updates

* Simplifies & beautifies everything
* Introduces a new Class system.
* Errors are defaulted to AWS's handler.
* New function names & more efficient handling.
* Should fix a majority of the errors.

Please read the README for more!
This commit is contained in:
Devang Srivastava 2020-09-28 15:32:51 +05:30
commit e6d7753dc8
1095 changed files with 45088 additions and 2911 deletions

View file

@ -10,11 +10,7 @@ class LockingSessionConnection extends StandardSessionConnection
{
public function __construct(DynamoDbClient $client, array $config = [])
{
parent::__construct($client, $config + [
'max_lock_wait_time' => 10,
'min_lock_retry_microtime' => 10000,
'max_lock_retry_microtime' => 50000,
]);
parent::__construct($client, $config);
}
/**
@ -26,7 +22,7 @@ class LockingSessionConnection extends StandardSessionConnection
// Create the params for the UpdateItem operation so that a lock can be
// set and item returned (via ReturnValues) in a one, atomic operation.
$params = [
'TableName' => $this->config['table_name'],
'TableName' => $this->getTableName(),
'Key' => $this->formatKey($id),
'Expected' => ['lock' => ['Exists' => false]],
'AttributeUpdates' => ['lock' => ['Value' => ['N' => '1']]],
@ -34,7 +30,7 @@ class LockingSessionConnection extends StandardSessionConnection
];
// Acquire the lock and fetch the item data.
$timeout = time() + $this->config['max_lock_wait_time'];
$timeout = time() + $this->getMaxLockWaitTime();
while (true) {
try {
$item = [];
@ -50,8 +46,8 @@ class LockingSessionConnection extends StandardSessionConnection
&& time() < $timeout
) {
usleep(rand(
$this->config['min_lock_retry_microtime'],
$this->config['max_lock_retry_microtime']
$this->getMinLockRetryMicrotime(),
$this->getMaxLockRetryMicrotime()
));
} else {
break;