Skip to content

Commit

Permalink
Add flush method to storages
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomasz Narloch committed Aug 18, 2016
1 parent 2886666 commit 77086d2
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
12 changes: 12 additions & 0 deletions libraries/joomla/cache/storage.php
Expand Up @@ -253,6 +253,18 @@ public function clean($group, $mode = null)
return true;
}

/**
* Flush all existing items in storage.
*
* @return boolean
*
* @since __DEPLOY_VERSION__
*/
public function flush()
{
return true;
}

/**
* Garbage collect expired cache data
*
Expand Down
17 changes: 17 additions & 0 deletions libraries/joomla/cache/storage/memcache.php
Expand Up @@ -278,6 +278,23 @@ public function clean($group, $mode = null)
return true;
}

/**
* Flush all existing items in storage.
*
* @return boolean
*
* @since __DEPLOY_VERSION__
*/
public function flush()
{
if (!$this->lockindex())
{
return false;
}

return static::$_db->flush();
}

/**
* Test to see if the storage handler is available.
*
Expand Down
17 changes: 17 additions & 0 deletions libraries/joomla/cache/storage/memcached.php
Expand Up @@ -294,6 +294,23 @@ public function clean($group, $mode = null)
return true;
}

/**
* Flush all existing items in storage.
*
* @return boolean
*
* @since __DEPLOY_VERSION__
*/
public function flush()
{
if (!$this->lockindex())
{
return false;
}

return static::$_db->flush();
}

/**
* Test to see if the storage handler is available.
*
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/core/case/cache.php
Expand Up @@ -62,7 +62,9 @@ protected function tearDown()

if ($this->handler instanceof JCacheStorage)
{
// Deprecated, temporary have to stay because flush method is not implemented in all storages.
$this->handler->clean($this->group);
$this->handler->flush();
}

parent::tearDown();
Expand Down

1 comment on commit 77086d2

@mbabker
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For most of the other adapters, you can reference the clear methods from https://github.com/joomla-framework/cache/tree/2.0-dev/src/Adapter to give the majority of them usable flush methods. The file storage probably won't transfer one-for-one though.

Please sign in to comment.