summaryrefslogtreecommitdiff
path: root/vendor/aws/aws-sdk-php/src/DynamoDb/SessionConnectionConfigTrait.php
blob: 371a932ddfae26c62ec835f2d34c34260fc4abcd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
<?php
namespace Aws\DynamoDb;

trait SessionConnectionConfigTrait
{
    /** @var string Name of table to store the sessions */
    protected $tableName = 'sessions';

    /** @var string Name of hash key in table. Default: "id" */
    protected $hashKey = 'id';

    /** @var string Name of the data attribute in table. Default: "data" */
    protected $dataAttribute = 'data';

    /** @var string Type of the data attribute in table. Default: "string" */
    protected $dataAttributeType = 'string';

    /** @var integer Lifetime of inactive sessions expiration */
    protected $sessionLifetime;

    /** @var string Name of the session life time attribute in table. Default: "expires" */
    protected $sessionLifetimeAttribute = 'expires';

    /** @var string Whether or not to use consistent reads */
    protected $consistentRead = true;

    /** @var string Batch options used for garbage collection */
    protected $batchConfig = [];

    /** @var boolean Whether or not to use session locking */
    protected $locking = false;

    /** @var integer Max time (s) to wait for lock acquisition */
    protected $maxLockWaitTime = 10;

    /** @var integer Min time (µs) to wait between lock attempts */
    protected $minLockRetryMicrotime = 10000;

    /** @var integer Max time (µs) to wait between lock attempts */
    protected $maxLockRetryMicrotime = 50000;

    /**
     * It initialize the Config class and
     * it sets values in case of valid configurations.
     * 
     * It transforms parameters underscore separated in camelcase "this_is_a_test" => ThisIsATest
     * and it uses it in order to set the values.
     * 
     * @param array $config
     */
    public function initConfig( array $config = [] )
    {
        if (!empty($config))
        {
            foreach ($config as $key => $value)
            {
                $method = 'set' . str_replace('_', '', ucwords($key, '_'));
                if(method_exists($this,$method))
                {
                    call_user_func_array(array($this, $method), array($value));
                }
            }
        }

        // It applies the default PHP session lifetime, if no session lifetime config is provided
        if(!isset($config['session_lifetime']))
        {
            $this->setSessionLifetime((int) ini_get('session.gc_maxlifetime'));
        }
    }

    /**
     * @return string
     */
    public function getTableName()
    {
        return $this->tableName;
    }

    /**
     * @param string $tableName
     */
    public function setTableName($tableName)
    {
        $this->tableName = $tableName;
    }

    /**
     * @return string
     */
    public function getHashKey()
    {
        return $this->hashKey;
    }

    /**
     * @param string $hashKey
     */
    public function setHashKey($hashKey)
    {
        $this->hashKey = $hashKey;
    }

    /**
     * @return string
     */
    public function getDataAttribute()
    {
        return $this->dataAttribute;
    }

    /**
     * @param string $dataAttribute
     */
    public function setDataAttribute($dataAttribute)
    {
        $this->dataAttribute = $dataAttribute;
    }

    /**
     * @return string
     */
    public function getDataAttributeType()
    {
        return $this->dataAttributeType;
    }

    /**
     * @param string $dataAttributeType
     */
    public function setDataAttributeType($dataAttributeType)
    {
        $this->dataAttributeType = $dataAttributeType;
    }

    /**
     * @return number
     */
    public function getSessionLifetime()
    {
        return $this->sessionLifetime;
    }

    /**
     * @param number $sessionLifetime
     */
    public function setSessionLifetime($sessionLifetime)
    {
        $this->sessionLifetime = $sessionLifetime;
    }

    /**
     * @return string
     */
    public function getSessionLifetimeAttribute()
    {
        return $this->sessionLifetimeAttribute;
    }

    /**
     * @param string $sessionLifetimeAttribute
     */
    public function setSessionLifetimeAttribute($sessionLifetimeAttribute)
    {
        $this->sessionLifetimeAttribute = $sessionLifetimeAttribute;
    }

    /**
     * @return boolean
     */
    public function isConsistentRead()
    {
        return $this->consistentRead;
    }

    /**
     * @param boolean $consistentRead
     */
    public function setConsistentRead($consistentRead)
    {
        $this->consistentRead = $consistentRead;
    }

    /**
     * @return mixed
     */
    public function getBatchConfig()
    {
        return $this->batchConfig;
    }

    /**
     * @param mixed $batchConfig
     */
    public function setBatchConfig($batchConfig)
    {
        $this->batchConfig = $batchConfig;
    }
    /**
     * @return boolean
     */
    public function isLocking()
    {
        return $this->locking;
    }

    /**
     * @param boolean $locking
     */
    public function setLocking($locking)
    {
        $this->locking = $locking;
    }

    /**
     * @return number
     */
    public function getMaxLockWaitTime()
    {
        return $this->maxLockWaitTime;
    }

    /**
     * @param number $maxLockWaitTime
     */
    public function setMaxLockWaitTime($maxLockWaitTime)
    {
        $this->maxLockWaitTime = $maxLockWaitTime;
    }

    /**
     * @return number
     */
    public function getMinLockRetryMicrotime()
    {
        return $this->minLockRetryMicrotime;
    }

    /**
     * @param number $minLockRetryMicrotime
     */
    public function setMinLockRetryMicrotime($minLockRetryMicrotime)
    {
        $this->minLockRetryMicrotime = $minLockRetryMicrotime;
    }

    /**
     * @return number
     */
    public function getMaxLockRetryMicrotime()
    {
        return $this->maxLockRetryMicrotime;
    }

    /**
     * @param number $maxLockRetryMicrotime
     */
    public function setMaxLockRetryMicrotime($maxLockRetryMicrotime)
    {
        $this->maxLockRetryMicrotime = $maxLockRetryMicrotime;
    }
}