@@ -60,43 +60,43 @@ instantiate :class:`Symfony\\Component\\Cache\\Simple\\FilesystemCache`::
60
60
Now you can create, retrieve, update and delete items using this object::
61
61
62
62
// save a new item in the cache
63
- $cache->set('stats.num_products ', 4711);
63
+ $cache->set('stats.products_count ', 4711);
64
64
65
65
// or set it with a custom ttl
66
- // $cache->set('stats.num_products ', 4711, 3600);
66
+ // $cache->set('stats.products_count ', 4711, 3600);
67
67
68
68
// retrieve the cache item
69
- if (!$cache->has('stats.num_products ')) {
69
+ if (!$cache->has('stats.products_count ')) {
70
70
// ... item does not exists in the cache
71
71
}
72
72
73
73
// retrieve the value stored by the item
74
- $numProducts = $cache->get('stats.num_products ');
74
+ $productsCount = $cache->get('stats.products_count ');
75
75
76
76
// or specify a default value, if the key doesn't exist
77
- // $numProducts = $cache->get('stats.num_products ', 100);
77
+ // $productsCount = $cache->get('stats.products_count ', 100);
78
78
79
79
// remove the cache key
80
- $cache->delete('stats.num_products ');
80
+ $cache->delete('stats.products_count ');
81
81
82
82
// clear *all* cache keys
83
83
$cache->clear();
84
84
85
85
You can also work with multiple items at once::
86
86
87
87
$cache->setMultiple(array(
88
- 'stats.num_products ' => 4711,
89
- 'stats.num_users ' => 1356,
88
+ 'stats.products_count ' => 4711,
89
+ 'stats.users_count ' => 1356,
90
90
));
91
91
92
92
$stats = $cache->getMultiple(array(
93
- 'stats.num_products ',
94
- 'stats.num_users ',
93
+ 'stats.products_count ',
94
+ 'stats.users_count ',
95
95
));
96
96
97
97
$cache->deleteMultiple(array(
98
- 'stats.num_products ',
99
- 'stats.num_users ',
98
+ 'stats.products_count ',
99
+ 'stats.users_count ',
100
100
));
101
101
102
102
Available Simple Cache (PSR-16) Classes
@@ -159,22 +159,22 @@ a filesystem-based cache, instantiate :class:`Symfony\\Component\\Cache\\Adapter
159
159
Now you can create, retrieve, update and delete items using this cache pool::
160
160
161
161
// create a new item by trying to get it from the cache
162
- $numProducts = $cache->getItem('stats.num_products ');
162
+ $productsCount = $cache->getItem('stats.products_count ');
163
163
164
164
// assign a value to the item and save it
165
- $numProducts ->set(4711);
166
- $cache->save($numProducts );
165
+ $productsCount ->set(4711);
166
+ $cache->save($productsCount );
167
167
168
168
// retrieve the cache item
169
- $numProducts = $cache->getItem('stats.num_products ');
170
- if (!$numProducts ->isHit()) {
169
+ $productsCount = $cache->getItem('stats.products_count ');
170
+ if (!$productsCount ->isHit()) {
171
171
// ... item does not exists in the cache
172
172
}
173
173
// retrieve the value stored by the item
174
- $total = $numProducts ->get();
174
+ $total = $productsCount ->get();
175
175
176
176
// remove the cache item
177
- $cache->deleteItem('stats.num_products ');
177
+ $cache->deleteItem('stats.products_count ');
178
178
179
179
For a list of all of the supported adapters, see :doc: `/components/cache/cache_pools `.
180
180
0 commit comments