From 76144f4fe72a3b2d8f2a9ba03a265e2b6ff145cf Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Fri, 22 May 2020 15:51:58 +1200 Subject: [PATCH 1/2] DOCS Clarify GC handling (fixes #39) --- README.md | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 79ac180..02c44d8 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,11 @@ If you wish to store sessions in DynamoDB, set the required environment variable Once these are in place, this module will configure DynamoDB and register that as the session handler. -Before you can actually use this, you need to create a table in which to store the sessions. This can be done through the [AWS Console for Amazon DynamoDB](https://console.aws.amazon.com/dynamodb/home), or using the SDK. When creating the table, you should set the primary key to `id` of type `string`. +Before you can actually use this, you need to create a table in which to store the sessions. +Follow the instructions in the [AWS SDK for PHP documentation](https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/service_dynamodb-session-handler.html#basic-usage). + +**IMPORTANT: You need to [set up a TTL attribute](https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/service_dynamodb-session-handler.html#ddbsh-garbage-collection) for garbage collection in your table. +The module does not provide automated garbage collection abilities.** ## Using DynamoDB outside of AWS @@ -40,26 +44,6 @@ in EC2 instances, as credentials are automatically handled by the IAM role insid AWS_ACCESS_KEY=my-access-key AWS_SECRET_KEY=my-secret -## Garbage collecting sessions - -Inactive sessions are garbage collected by `GarbageCollectSessionCronTask` if [silverstripe-crontask](https://github.com/silverstripe-labs/silverstripe-crontask) -is setup on your instance. The time when a session should be collected after inactivity can be changed by setting -`Session::$timeout`. - -For example, in your application's config YAML file, this sets a 20 minute session timeout: - - Session: - timeout: 1200 - -You can also set the DynamoDB garbage collection time independently of `Session::$timeout`, but it's recommended you -make it at least the value of `Session::$timeout` or greater. - -For example, in your `_ss_environment.php` file, set garbage collection after 1 hour of inactivity in sessions: - - define('AWS_DYNAMODB_SESSION_LIFETIME', 3600); - -See https://docs.aws.amazon.com/aws-sdk-php/v3/guide/service/dynamodb-session-handler.html for more information. - ## Local Testing You can simulate DynamoDB locally for easier development through [DynamoDB Local](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/SettingUp.html). From 36b203100798c73b00dac3202c0e76bddc4c8cc2 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Fri, 22 May 2020 16:48:13 +1200 Subject: [PATCH 2/2] Remove unused crontask dependency No longer providing garbage collection since https://github.com/silverstripe/silverstripe-dynamodb/commit/d91baf50a890570258805fde86051bd86eb96d4b#diff-003cb34625bfaea8be18fd87cd2d3afc --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index 85abfbb..30811af 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,6 @@ "require": { "aws/aws-sdk-php": "~3.105", "doctrine/cache": "1.*", - "silverstripe/crontask": "*", "silverstripe/framework": "^4@dev" }, "require-dev": {