User tests: Successful: Unsuccessful:
#11565 added support for flushing the full cache and is only implemented for Memcache(d) right now. Implement it for more of the adapters.
Calling the flush()
method of the cache storage adapter causes the cache store to be flushed. JFactory::getCache()->flush()
.
N/A
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
Labels |
Added:
?
|
i've tested with redis using JFactory::getCache()->_getStorage()->flush();
since FLUSHDB
Delete all the keys of the currently selected DB
should be used very carefully
I have tested this item
with redis
Hum so could this have a side effect and flush sessions too?
Hum so could this have a side effect and flush sessions too?
They all could and probably will have side effects honestly. Unless we force our code to use different servers for cache and session or write the methods to loop through the entire cache store and only remove stuff explicitly added by the cache handler, it's going to delete everything as instructed by each handler's flush API (the only one without side effects is the filesystem handler unless you've got your sessions configured to use the cache directory, in which case, I'm only going to sit back and laugh when you come up with a bug report about that scenario).
Category | Libraries | ⇒ | Libraries Unit Tests |
Labels |
Added:
?
|
shouldn't we have unit tests for this?
Done.
(the only one without side effects is the filesystem handler unless you've got your sessions configured to use the cache directory, in which case, I'm only going to sit back and laugh when you come up with a bug report about that scenario).
ehehehhe
I have tested this item
I have prepared console.php file to include joomla dependencies.
$ php -a -dauto_prepend_file=console.php
Interactive mode enabled
php > $cache = JFactory::getCache('', 'output');
php > print_r($cache->options);
Array
(
[cachebase] => [...]/demo/cache
[lifetime] => 5
[language] => en-GB
[storage] => file
[defaultgroup] =>
[locking] => 1
[locktime] => 15
[checkTime] => 1
[caching] => 1
)
php > var_dump($cache->_getStorage()->getAll());
array(0) {
}
php > var_dump($cache->store('some data', 'id', 'group'));
bool(true)
php > var_dump($cache->store('some data2', 'id2', 'group2'));
bool(true)
php > var_dump($cache->_getStorage()->getAll());
array(2) {
["group2"]=>
object(JCacheStorageHelper)#23 (3) {
["group"]=>
string(6) "group2"
["size"]=>
string(4) "0.08"
["count"]=>
int(2)
}
["group"]=>
object(JCacheStorageHelper)#24 (3) {
["group"]=>
string(5) "group"
["size"]=>
string(4) "0.08"
["count"]=>
int(2)
}
}
php > var_dump($cache->_getStorage()->flush());
bool(true)
php > var_dump($cache->_getStorage()->getAll());
array(0) {
}
## ADDITIONAL TEST
php > var_dump($cache->_getStorage()->get('id', 'group'));
bool(false)
php > var_dump($cache->_getStorage()->getAll());
array(1) {
["group"]=>
object(JCacheStorageHelper)#21 (3) {
["group"]=>
string(5) "group"
["size"]=>
string(4) "0.03"
["count"]=>
int(1)
}
}
php > var_dump($cache->_getStorage()->flush());
bool(true)
php > var_dump($cache->_getStorage()->getAll());
array(0) {
}
## TEST APCU
php > $cache->options['storage'] = 'apcu';
php > var_dump($cache->_getStorage()->getAll());
array(0) {
}
php > var_dump($cache->store('some data', 'id', 'group'));
bool(true)
php > var_dump($cache->store('some data2', 'id2', 'group2'));
bool(true)
php > var_dump($cache->_getStorage()->getAll());
array(2) {
["group2"]=>
object(JCacheStorageHelper)#22 (3) {
["group"]=>
string(6) "group2"
["size"]=>
string(4) "0.64"
["count"]=>
int(1)
}
["group"]=>
object(JCacheStorageHelper)#23 (3) {
["group"]=>
string(5) "group"
["size"]=>
string(4) "0.64"
["count"]=>
int(1)
}
}
php > var_dump($cache->_getStorage()->flush());
bool(true)
php > var_dump($cache->_getStorage()->getAll());
array(0) {
}
... well?
I have tested this item
Labels |
Added:
?
Removed: ? |
Labels |
Added:
?
Removed: ? |
Well, if someone wants to do one more test/review and then anyone but me hit merge then it's fine.
No interest, fine.
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-11-12 16:00:43 |
Closed_By | ⇒ | mbabker |
can you reopen I’ll test, sorry didn’t see this.
can't reopen, get "422 RuntimeException". Guess the PR is deleted.
shouldn't we have unit tests for this? or for another PR?