-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit. Added connection handler and keyvalue implementation
- Loading branch information
0 parents
commit 1bc5155
Showing
15 changed files
with
1,572 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "drupal/dynamodb_client", | ||
"type": "drupal-module", | ||
"description": "Client interface use for communication with Amazon DynamoDB", | ||
"homepage": "http://drupal.org/project/dynamodb_client", | ||
"license": "GPL-2.0+", | ||
"minimum-stability": "dev", | ||
"require": { | ||
"aws/aws-sdk-php": "^3" | ||
} | ||
} |
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,5 @@ | ||
name: 'Amazon DynamoDB' | ||
type: module | ||
description: 'Client interface for Amazon DynamoDB' | ||
core_version_requirement: ^8.9 || ^9 | ||
package: Performance |
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,8 @@ | ||
services: | ||
dynamodb_client.client_factory: | ||
class: Drupal\dynamodb_client\ClientFactory | ||
arguments: [ default ] | ||
|
||
dynamodb_client.connection: | ||
class: Drupal\dynamodb_client\Connection | ||
arguments: ['@settings'] |
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,5 @@ | ||
name: 'Amazon DynamoDB Key/Value' | ||
type: module | ||
description: 'Amazon DynamoDB Key/Value storage implementation for Drupal 8/9' | ||
core_version_requirement: ^8.9 || ^9 | ||
package: Performance |
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,109 @@ | ||
<?php | ||
|
||
use Drupal\dynamodb_client\DynamoDb; | ||
|
||
/** | ||
* Implements hook_install(). | ||
*/ | ||
function dynamodb_keyvalue_install() { | ||
$connection = DynamoDb::connection(); | ||
foreach (dynamodb_keyvalue_tables_definition() as $id => $table) { | ||
$billing = DynamoDb::getBillingMode($id); | ||
$table += $billing; | ||
$connection->createTable($table); | ||
} | ||
|
||
} | ||
|
||
/** | ||
* Implements hook_uninstall(). | ||
*/ | ||
function dynamodb_keyvalue_uninstall() { | ||
$connection = DynamoDb::connection(); | ||
$connection->deleteTable(['TableName' => 'key_value']); | ||
$connection->deleteTable(['TableName' => 'key_value_expire']); | ||
} | ||
|
||
/** | ||
* Definition for tables. | ||
* | ||
* @return array[] | ||
* Return keyed array of tables. | ||
*/ | ||
function dynamodb_keyvalue_tables_definition() { | ||
return [ | ||
'key_value' => [ | ||
'TableName' => 'key_value', | ||
'AttributeDefinitions' => [ | ||
[ | ||
'AttributeName' => 'collection', | ||
'AttributeType' => 'S' | ||
], | ||
[ | ||
'AttributeName' => 'name', | ||
'AttributeType' => 'S' | ||
], | ||
], | ||
'KeySchema' => [ | ||
[ | ||
'AttributeName' => 'collection', | ||
'KeyType' => 'HASH' //Partition key | ||
], | ||
[ | ||
'AttributeName' => 'name', | ||
'KeyType' => 'RANGE' //Sort key | ||
], | ||
], | ||
], | ||
'key_value_expire' => [ | ||
'TableName' => 'key_value_expire', | ||
'AttributeDefinitions' => [ | ||
[ | ||
'AttributeName' => 'collection', | ||
'AttributeType' => 'S', | ||
], | ||
[ | ||
'AttributeName' => 'name', | ||
'AttributeType' => 'S', | ||
], | ||
[ | ||
'AttributeName' => 'expire', | ||
'AttributeType' => 'N', | ||
], | ||
], | ||
'LocalSecondaryIndexes' => [ | ||
[ | ||
'IndexName' => 'expired_index', | ||
'KeySchema' => [ | ||
[ | ||
'AttributeName' => 'collection', | ||
'KeyType' => 'HASH' | ||
], | ||
[ | ||
'AttributeName' => 'expire', | ||
'KeyType' => 'RANGE' | ||
], | ||
], | ||
'Projection' => [ | ||
'ProjectionType' => 'INCLUDE', | ||
'NonKeyAttributes' => ['name'] | ||
] | ||
], | ||
], | ||
'KeySchema' => [ | ||
[ | ||
'AttributeName' => 'collection', | ||
'KeyType' => 'HASH' | ||
], | ||
[ | ||
'AttributeName' => 'name', | ||
'KeyType' => 'RANGE' | ||
], | ||
], | ||
'TimeToLiveSpecification' => [ | ||
'Enabled' => TRUE, | ||
'AttributeName' => 'expire', | ||
], | ||
] | ||
]; | ||
} |
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,13 @@ | ||
services: | ||
keyvalue.dynamodb: | ||
class: Drupal\dynamodb_keyvalue\KeyValueStore\KeyValueDynamoDbFactory | ||
arguments: ['@serialization.phpserialize', '@dynamodb_client.connection'] | ||
|
||
keyvalue.expirable.dynamodb: | ||
class: Drupal\dynamodb_keyvalue\KeyValueStore\KeyValueDynamoDbExpirableFactory | ||
arguments: [ '@serialization.phpserialize', '@dynamodb_client.connection'] | ||
|
||
dynamodb_keyvalue.migrate: | ||
class: Drupal\dynamodb_keyvalue\MigrateDatabaseKeyValue | ||
arguments: | ||
[ '@database', '@serialization.yaml', '@dynamodb_client.connection' ] |
Oops, something went wrong.