1 | <?php |
||
11 | class DynamoDbSessionHandler implements \SessionHandlerInterface |
||
12 | { |
||
13 | |||
14 | /** |
||
15 | * @var SessionHandler |
||
16 | */ |
||
17 | private $sessionHandler; |
||
18 | |||
19 | /** |
||
20 | * Constructor. |
||
21 | * |
||
22 | * See: http://docs.aws.amazon.com/aws-sdk-php/guide/latest/feature-dynamodb-session-handler.html#configuration |
||
23 | * |
||
24 | * List of available options: |
||
25 | * * table_name: The name of the DynamoDB table in which to store the sessions. This defaults to sessions. |
||
26 | * * hash_key: The name of the hash key in the DynamoDB sessions table. This defaults to id. |
||
27 | * * session_lifetime: The lifetime of an inactive session before it should be garbage collected. If it is not provided, then the actual lifetime value that will be used is ini_get('session.gc_maxlifetime'). |
||
28 | * * consistent_read: Whether or not the session handler should use consistent reads for the GetItem operation. This defaults to true. |
||
29 | * * locking_strategy: The strategy used for doing session locking. By default the handler uses the NullLockingStrategy, which means that session locking is not enabled (see the Session Locking section for more information). Valid values for this option include null, 'null', 'pessemistic', or an instance of NullLockingStrategy or PessimisticLockingStrategy |
||
30 | * * automatic_gc: Whether or not to use PHP's session auto garbage collection. This defaults to the value of (bool) ini_get('session.gc_probability'), but the recommended value is false. (see the Garbage Collection section for more information). |
||
31 | * * gc_batch_size: The batch size used for removing expired sessions during garbage collection. This defaults to 25, which is the maximum size of a single BatchWriteItem operation. This value should also take your provisioned throughput into account as well as the timing of your garbage collection. |
||
32 | * * gc_operation_delay: The delay (in seconds) between service operations performed during garbage collection. This defaults to 0. Increasing this value allows you to throttle your own requests in an attempt to stay within your provisioned throughput capacity during garbage collection. |
||
33 | * * max_lock_wait_time: Maximum time (in seconds) that the session handler should wait to acquire a lock before giving up. This defaults to 10 and is only used with the PessimisticLockingStrategy. |
||
34 | * * min_lock_retry_microtime: Minimum time (in microseconds) that the session handler should wait between attempts to acquire a lock. This defaults to 10000 and is only used with the PessimisticLockingStrategy. |
||
35 | * * max_lock_retry_microtime: Maximum time (in microseconds) that the session handler should wait between attempts to acquire a lock. This defaults to 50000 and is only used with the PessimisticLockingStrategy. |
||
36 | * |
||
37 | * @param Aws $aws The AWS SDK for PHP |
||
38 | * @param array $options An associative array of field options (see above) |
||
39 | */ |
||
40 | 6 | public function __construct(Aws $aws, array $options) |
|
44 | |||
45 | /** |
||
46 | * {@inheritdoc} |
||
47 | */ |
||
48 | 1 | public function open($savePath, $sessionName) |
|
52 | |||
53 | /** |
||
54 | * {@inheritdoc} |
||
55 | */ |
||
56 | 1 | public function close() |
|
62 | |||
63 | /** |
||
64 | * {@inheritdoc} |
||
65 | */ |
||
66 | 1 | public function destroy($sessionId) |
|
72 | |||
73 | /** |
||
74 | * {@inheritdoc} |
||
75 | */ |
||
76 | 1 | public function gc($maxLifetime) |
|
82 | |||
83 | /** |
||
84 | * {@inheritdoc} |
||
85 | */ |
||
86 | 1 | public function write($sessionId, $data) |
|
93 | |||
94 | /** |
||
95 | * {@inheritdoc} |
||
96 | */ |
||
97 | 1 | public function read($sessionId) |
|
103 | |||
104 | } |
||
105 |