-
Notifications
You must be signed in to change notification settings - Fork 11.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
integrate dynamodb cache and session driver
- Loading branch information
1 parent
8071e06
commit ea745e1
Showing
5 changed files
with
664 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace Illuminate\Cache; | ||
|
||
use Illuminate\Cache\Lock; | ||
use Aws\DynamoDb\DynamoDbClient; | ||
|
||
class DynamoDbLock extends Lock | ||
{ | ||
/** | ||
* The DynamoDB client instance. | ||
* | ||
* @var \Illuminate\Cache\DynamoDbStore | ||
*/ | ||
protected $dynamo; | ||
|
||
/** | ||
* Create a new lock instance. | ||
* | ||
* @param \Illuminate\Cache\DynamoDbStore $dynamo | ||
* @param string $name | ||
* @param int $seconds | ||
* @return void | ||
*/ | ||
public function __construct(DynamoDbStore $dynamo, $name, $seconds) | ||
{ | ||
parent::__construct($name, $seconds); | ||
|
||
$this->dynamo = $dynamo; | ||
} | ||
|
||
/** | ||
* Attempt to acquire the lock. | ||
* | ||
* @return bool | ||
*/ | ||
public function acquire() | ||
{ | ||
return $this->dynamo->add( | ||
$this->name, 1, $this->seconds / 60 | ||
); | ||
} | ||
|
||
/** | ||
* Release the lock. | ||
* | ||
* @return void | ||
*/ | ||
public function release() | ||
{ | ||
$this->dynamo->forget($this->name); | ||
} | ||
} |
Oops, something went wrong.