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