Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
namespace Aws\DynamoDb;
3
 
4
trait SessionConnectionConfigTrait
5
{
6
    /** @var string Name of table to store the sessions */
7
    protected $tableName = 'sessions';
8
 
9
    /** @var string Name of hash key in table. Default: "id" */
10
    protected $hashKey = 'id';
11
 
12
    /** @var string Name of the data attribute in table. Default: "data" */
13
    protected $dataAttribute = 'data';
14
 
15
    /** @var string Type of the data attribute in table. Default: "string" */
16
    protected $dataAttributeType = 'string';
17
 
18
    /** @var integer Lifetime of inactive sessions expiration */
19
    protected $sessionLifetime;
20
 
21
    /** @var string Name of the session life time attribute in table. Default: "expires" */
22
    protected $sessionLifetimeAttribute = 'expires';
23
 
24
    /** @var string Whether or not to use consistent reads */
25
    protected $consistentRead = true;
26
 
27
    /** @var string Batch options used for garbage collection */
28
    protected $batchConfig = [];
29
 
30
    /** @var boolean Whether or not to use session locking */
31
    protected $locking = false;
32
 
33
    /** @var integer Max time (s) to wait for lock acquisition */
34
    protected $maxLockWaitTime = 10;
35
 
36
    /** @var integer Min time (µs) to wait between lock attempts */
37
    protected $minLockRetryMicrotime = 10000;
38
 
39
    /** @var integer Max time (µs) to wait between lock attempts */
40
    protected $maxLockRetryMicrotime = 50000;
41
 
42
    /**
43
     * It initialize the Config class and
44
     * it sets values in case of valid configurations.
45
     *
46
     * It transforms parameters underscore separated in camelcase "this_is_a_test" => ThisIsATest
47
     * and it uses it in order to set the values.
48
     *
49
     * @param array $config
50
     */
51
    public function initConfig( array $config = [] )
52
    {
53
        if (!empty($config))
54
        {
55
            foreach ($config as $key => $value)
56
            {
57
                $method = 'set' . str_replace('_', '', ucwords($key, '_'));
58
                if(method_exists($this,$method))
59
                {
60
                    call_user_func_array(array($this, $method), array($value));
61
                }
62
            }
63
        }
64
 
65
        // It applies the default PHP session lifetime, if no session lifetime config is provided
66
        if(!isset($config['session_lifetime']))
67
        {
68
            $this->setSessionLifetime((int) ini_get('session.gc_maxlifetime'));
69
        }
70
    }
71
 
72
    /**
73
     * @return string
74
     */
75
    public function getTableName()
76
    {
77
        return $this->tableName;
78
    }
79
 
80
    /**
81
     * @param string $tableName
82
     */
83
    public function setTableName($tableName)
84
    {
85
        $this->tableName = $tableName;
86
    }
87
 
88
    /**
89
     * @return string
90
     */
91
    public function getHashKey()
92
    {
93
        return $this->hashKey;
94
    }
95
 
96
    /**
97
     * @param string $hashKey
98
     */
99
    public function setHashKey($hashKey)
100
    {
101
        $this->hashKey = $hashKey;
102
    }
103
 
104
    /**
105
     * @return string
106
     */
107
    public function getDataAttribute()
108
    {
109
        return $this->dataAttribute;
110
    }
111
 
112
    /**
113
     * @param string $dataAttribute
114
     */
115
    public function setDataAttribute($dataAttribute)
116
    {
117
        $this->dataAttribute = $dataAttribute;
118
    }
119
 
120
    /**
121
     * @return string
122
     */
123
    public function getDataAttributeType()
124
    {
125
        return $this->dataAttributeType;
126
    }
127
 
128
    /**
129
     * @param string $dataAttributeType
130
     */
131
    public function setDataAttributeType($dataAttributeType)
132
    {
133
        $this->dataAttributeType = $dataAttributeType;
134
    }
135
 
136
    /**
137
     * @return number
138
     */
139
    public function getSessionLifetime()
140
    {
141
        return $this->sessionLifetime;
142
    }
143
 
144
    /**
145
     * @param number $sessionLifetime
146
     */
147
    public function setSessionLifetime($sessionLifetime)
148
    {
149
        $this->sessionLifetime = $sessionLifetime;
150
    }
151
 
152
    /**
153
     * @return string
154
     */
155
    public function getSessionLifetimeAttribute()
156
    {
157
        return $this->sessionLifetimeAttribute;
158
    }
159
 
160
    /**
161
     * @param string $sessionLifetimeAttribute
162
     */
163
    public function setSessionLifetimeAttribute($sessionLifetimeAttribute)
164
    {
165
        $this->sessionLifetimeAttribute = $sessionLifetimeAttribute;
166
    }
167
 
168
    /**
169
     * @return boolean
170
     */
171
    public function isConsistentRead()
172
    {
173
        return $this->consistentRead;
174
    }
175
 
176
    /**
177
     * @param boolean $consistentRead
178
     */
179
    public function setConsistentRead($consistentRead)
180
    {
181
        $this->consistentRead = $consistentRead;
182
    }
183
 
184
    /**
185
     * @return mixed
186
     */
187
    public function getBatchConfig()
188
    {
189
        return $this->batchConfig;
190
    }
191
 
192
    /**
193
     * @param mixed $batchConfig
194
     */
195
    public function setBatchConfig($batchConfig)
196
    {
197
        $this->batchConfig = $batchConfig;
198
    }
199
    /**
200
     * @return boolean
201
     */
202
    public function isLocking()
203
    {
204
        return $this->locking;
205
    }
206
 
207
    /**
208
     * @param boolean $locking
209
     */
210
    public function setLocking($locking)
211
    {
212
        $this->locking = $locking;
213
    }
214
 
215
    /**
216
     * @return number
217
     */
218
    public function getMaxLockWaitTime()
219
    {
220
        return $this->maxLockWaitTime;
221
    }
222
 
223
    /**
224
     * @param number $maxLockWaitTime
225
     */
226
    public function setMaxLockWaitTime($maxLockWaitTime)
227
    {
228
        $this->maxLockWaitTime = $maxLockWaitTime;
229
    }
230
 
231
    /**
232
     * @return number
233
     */
234
    public function getMinLockRetryMicrotime()
235
    {
236
        return $this->minLockRetryMicrotime;
237
    }
238
 
239
    /**
240
     * @param number $minLockRetryMicrotime
241
     */
242
    public function setMinLockRetryMicrotime($minLockRetryMicrotime)
243
    {
244
        $this->minLockRetryMicrotime = $minLockRetryMicrotime;
245
    }
246
 
247
    /**
248
     * @return number
249
     */
250
    public function getMaxLockRetryMicrotime()
251
    {
252
        return $this->maxLockRetryMicrotime;
253
    }
254
 
255
    /**
256
     * @param number $maxLockRetryMicrotime
257
     */
258
    public function setMaxLockRetryMicrotime($maxLockRetryMicrotime)
259
    {
260
        $this->maxLockRetryMicrotime = $maxLockRetryMicrotime;
261
    }
262
}