commit | author | age
|
2207d6
|
1 |
# Memcache |
W |
2 |
|
|
3 |
|
|
4 |
Connects to [memcached](http://www.memcached.org/) using either _Memcache_ or _Memcached_ extension. |
|
5 |
|
|
6 |
Performs a cleanup by flushing all values after each test run. |
|
7 |
|
|
8 |
## Status |
|
9 |
|
|
10 |
* Maintainer: **davert** |
|
11 |
* Stability: **beta** |
|
12 |
* Contact: davert@codeception.com |
|
13 |
|
|
14 |
## Configuration |
|
15 |
|
|
16 |
* **`host`** (`string`, default `'localhost'`) - The memcached host |
|
17 |
* **`port`** (`int`, default `11211`) - The memcached port |
|
18 |
|
|
19 |
### Example (`unit.suite.yml`) |
|
20 |
|
|
21 |
```yaml |
|
22 |
modules: |
|
23 |
- Memcache: |
|
24 |
host: 'localhost' |
|
25 |
port: 11211 |
|
26 |
``` |
|
27 |
|
|
28 |
Be sure you don't use the production server to connect. |
|
29 |
|
|
30 |
## Public Properties |
|
31 |
|
|
32 |
* **memcache** - instance of _Memcache_ or _Memcached_ object |
|
33 |
|
|
34 |
|
|
35 |
## Actions |
|
36 |
|
|
37 |
### clearMemcache |
|
38 |
|
|
39 |
Flushes all Memcached data. |
|
40 |
|
|
41 |
|
|
42 |
### dontSeeInMemcached |
|
43 |
|
|
44 |
Checks item in Memcached doesn't exist or is the same as expected. |
|
45 |
|
|
46 |
Examples: |
|
47 |
|
|
48 |
``` php |
|
49 |
<?php |
|
50 |
// With only one argument, only checks the key does not exist |
|
51 |
$I->dontSeeInMemcached('users_count'); |
|
52 |
|
|
53 |
// Checks a 'users_count' exists does not exist or its value is not the one provided |
|
54 |
$I->dontSeeInMemcached('users_count', 200); |
|
55 |
?> |
|
56 |
``` |
|
57 |
|
|
58 |
* `param` $key |
|
59 |
* `param` $value |
|
60 |
|
|
61 |
|
|
62 |
### grabValueFromMemcached |
|
63 |
|
|
64 |
Grabs value from memcached by key. |
|
65 |
|
|
66 |
Example: |
|
67 |
|
|
68 |
``` php |
|
69 |
<?php |
|
70 |
$users_count = $I->grabValueFromMemcached('users_count'); |
|
71 |
?> |
|
72 |
``` |
|
73 |
|
|
74 |
* `param` $key |
|
75 |
* `return` array|string |
|
76 |
|
|
77 |
|
|
78 |
### haveInMemcached |
|
79 |
|
|
80 |
Stores an item `$value` with `$key` on the Memcached server. |
|
81 |
|
|
82 |
* `param string` $key |
|
83 |
* `param mixed` $value |
|
84 |
* `param int` $expiration |
|
85 |
|
|
86 |
|
|
87 |
### seeInMemcached |
|
88 |
|
|
89 |
Checks item in Memcached exists and the same as expected. |
|
90 |
|
|
91 |
Examples: |
|
92 |
|
|
93 |
``` php |
|
94 |
<?php |
|
95 |
// With only one argument, only checks the key exists |
|
96 |
$I->seeInMemcached('users_count'); |
|
97 |
|
|
98 |
// Checks a 'users_count' exists and has the value 200 |
|
99 |
$I->seeInMemcached('users_count', 200); |
|
100 |
?> |
|
101 |
``` |
|
102 |
|
|
103 |
* `param` $key |
|
104 |
* `param` $value |
|
105 |
|
|
106 |
<p> </p><div class="alert alert-warning">Module reference is taken from the source code. <a href="https://github.com/Codeception/Codeception/tree/2.5/src/Codeception/Module/Memcache.php">Help us to improve documentation. Edit module reference</a></div> |