Skip to content
This repository has been archived by the owner on Nov 25, 2022. It is now read-only.

Commit

Permalink
Renamed CS_Cache_Object to Data_Cache and renamed all its helpers fun…
Browse files Browse the repository at this point in the history
…ctions.
  • Loading branch information
bkader committed May 27, 2018
1 parent 6d9e0e5 commit 9c8c4aa
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 55 deletions.
2 changes: 1 addition & 1 deletion application/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* order to cache objects and anything cross-files.
* @since 2.1.0
*/
// _start_cache_object(array('group1', 'group2'));
// start_data_cache(array('group1', 'group2'));

// ------------------------------------------------------------------------
// YOU MAY EDIT LINES BELOW.
Expand Down
18 changes: 9 additions & 9 deletions skeleton/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -468,10 +468,10 @@ function _csk_reserved_module($module = null)

// ------------------------------------------------------------------------

if ( ! function_exists('_start_cache_object'))
if ( ! function_exists('start_data_cache'))
{
/**
* Starts Skeleton cache object. internal access only.
* Starts Skeleton Data_Cache object. internal access only.
*
* Make sure to call this function at the beginning of application
* "bootstrap.php" file.
Expand All @@ -482,19 +482,19 @@ function _csk_reserved_module($module = null)
* @param array $groups Groups to initialize (Optional)
* @return void
*/
function _start_cache_object($groups = null)
function start_data_cache($groups = null)
{
if ( ! function_exists('cs_cache_init'))
if ( ! function_exists('data_cache_init'))
{
require_once(KBPATH.'third_party/bkader/class-cache-object.php');
require_once(KBPATH.'third_party/bkader/class-data-cache.php');
}

if (function_exists('cs_cache_init'))
if (function_exists('data_cache_init'))
{
// We start the cache object.
cs_cache_init();
data_cache_init();

if (function_exists('cs_cache_add_groups'))
if (function_exists('data_cache_add_groups'))
{
// Default groups.
$default = array(
Expand All @@ -513,7 +513,7 @@ function _start_cache_object($groups = null)
$groups = $default;
}

cs_cache_add_groups($groups);
data_cache_add_groups($groups);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
defined('BASEPATH') OR exit('No direct script access allowed');

/**
* CS_Cache_object
* Data_Cache
*
* This class and its helpers can used to store anything in the global scope
* in order to reduce DB access for example. The cache object stores all of
Expand All @@ -54,7 +54,7 @@
* @since 2.1.0
* @version 2.1.0
*/
class CS_Cache_object {
class Data_Cache {

/**
* Holds an array of the cached objects.
Expand Down Expand Up @@ -197,7 +197,7 @@ public function __destruct()
public function add($key, $data, $group = 'default')
{
// We don't proceed if cache is suspended.
if (cs_suspend_cache())
if (data_cache_suspend())
{
return false;
}
Expand Down Expand Up @@ -511,7 +511,7 @@ private function _exists($key, $group)
// Helpers.
// ------------------------------------------------------------------------

if ( ! function_exists('cs_suspend_cache'))
if ( ! function_exists('data_cache_suspend'))
{
/**
* This method is used to temporary suspend cache. No more data can be
Expand All @@ -525,7 +525,7 @@ private function _exists($key, $group)
* @param bool $suspend Suspends the cache if true, enables it if false.
* @return bool The current suspension status.
*/
function cs_suspend_cache($suspend = null)
function data_cache_suspend($suspend = null)
{
static $suspended = false;

Expand All @@ -537,37 +537,37 @@ function cs_suspend_cache($suspend = null)

// ------------------------------------------------------------------------

if ( ! function_exists('cache_instance'))
if ( ! function_exists('data_cache_instance'))
{
/**
* Returns an instance of CS_Cache_object object.
* Returns an instance of Data_Cache object.
* @param void
* @return object
*/
function cache_instance()
function data_cache_instance()
{
return CS_Cache_object::instance();
return Data_Cache::instance();
}
}

// ------------------------------------------------------------------------

if ( ! function_exists('cs_cache_init'))
if ( ! function_exists('data_cache_init'))
{
/**
* Sets up Object Cache Global and assigns it.
* @param none
* @return void
*/
function cs_cache_init()
function data_cache_init()
{
$GLOBALS['cs_cache'] = new CS_Cache_object();
$GLOBALS['cs_cache'] = new Data_Cache();
}
}

// ------------------------------------------------------------------------

if ( ! function_exists('cs_cache_add'))
if ( ! function_exists('data_cache_add'))
{
/**
* Adds data to the cache if it does not already exist.
Expand All @@ -577,31 +577,31 @@ function cs_cache_init()
* @param string $group Where to group the cache content. Default "defautl".
* @return bool true if data added, false on error or key existence.
*/
function cs_cache_add($key, $data, $group = '')
function data_cache_add($key, $data, $group = '')
{
return cache_instance()->add($key, $data, $group);
return data_cache_instance()->add($key, $data, $group);
}
}

// ------------------------------------------------------------------------

if ( ! function_exists('cs_cache_add_groups'))
if ( ! function_exists('data_cache_add_groups'))
{
/**
* Sets the list of global cache groups.
* @access public
* @param mixed $groups Array, string or comma-separated string.
* @return void
*/
function cs_cache_add_groups($groups)
function data_cache_add_groups($groups)
{
return cache_instance()->add_groups($groups);
return data_cache_instance()->add_groups($groups);
}
}

// ------------------------------------------------------------------------

if ( ! function_exists('cs_cache_set'))
if ( ! function_exists('data_cache_set'))
{
/**
* Sets the data contents into the cache.
Expand All @@ -617,15 +617,15 @@ function cs_cache_add_groups($groups)
* @param string $group Where to group the cache contents. Default 'default'.
* @return bool Always returns true.
*/
function cs_cache_set($key, $data, $group = '')
function data_cache_set($key, $data, $group = '')
{
return cache_instance()->set($key, $data, $group);
return data_cache_instance()->set($key, $data, $group);
}
}

// ------------------------------------------------------------------------

if ( ! function_exists('cs_cache_get'))
if ( ! function_exists('data_cache_get'))
{
/**
* Retrieves the cache contents, if it exists.
Expand All @@ -642,15 +642,15 @@ function cs_cache_set($key, $data, $group = '')
* @param bool $found Whether the key was found in the cache (passed by reference).
* @return mixed false on failure to retrieve contents or the cache contents on success.
*/
function cs_cache_get($key, $group = '', &$found = null)
function data_cache_get($key, $group = '', &$found = null)
{
return cache_instance()->get($key, $group, $found);
return data_cache_instance()->get($key, $group, $found);
}
}

// ------------------------------------------------------------------------

if ( ! function_exists('cs_cache_replace'))
if ( ! function_exists('data_cache_replace'))
{
/**
* Replaces the contents in the cache, if contents already exist.
Expand All @@ -660,15 +660,15 @@ function cs_cache_get($key, $group = '', &$found = null)
* @param string $group Where to group the cache contents. Default 'default'.
* @return bool False if not exists, true if contents were replaced.
*/
function cs_cache_replace($key, $data, $group = '')
function data_cache_replace($key, $data, $group = '')
{
return cache_instance()->replace($key, $data, $group);
return data_cache_instance()->replace($key, $data, $group);
}
}

// ------------------------------------------------------------------------

if ( ! function_exists('cs_cache_delete'))
if ( ! function_exists('data_cache_delete'))
{
/**
* Removes the contents of the cache key in the group if it exists.
Expand All @@ -677,47 +677,47 @@ function cs_cache_replace($key, $data, $group = '')
* @param string $group Optional. Where the cache contents are grouped. Default 'default'.
* @return bool true if the contents were deleted, else false.
*/
function cs_cache_delete($key, $group = '')
function data_cache_delete($key, $group = '')
{
return cache_instance()->delete($key, $group);
return data_cache_instance()->delete($key, $group);
}
}

// ------------------------------------------------------------------------

if ( ! function_exists('cs_cache_reset'))
if ( ! function_exists('data_cache_reset'))
{
/**
* Resets all cache keys.
* @access public
* @param none
* @return void
*/
function cs_cache_reset()
function data_cache_reset()
{
return cache_instance()->reset();
return data_cache_instance()->reset();
}
}

// ------------------------------------------------------------------------

if ( ! function_exists('cs_cache_flush'))
if ( ! function_exists('data_cache_flush'))
{
/**
* Clears the object cache of all data.
* @access public
* @param none
* @return bool Always returns true.
*/
function cs_cache_flush()
function data_cache_flush()
{
return cache_instance()->flush();
return data_cache_instance()->flush();
}
}

// ------------------------------------------------------------------------

if ( ! function_exists('cs_cache_increment'))
if ( ! function_exists('data_cache_increment'))
{
/**
* Increments numeric cache item's value.
Expand All @@ -727,15 +727,15 @@ function cs_cache_flush()
* @param string $group The group the key is in. Default 'default'.
* @return mixed the item's new value if incremented, else false.
*/
function cs_cache_increment($key, $offset = 1, $group = '')
function data_cache_increment($key, $offset = 1, $group = '')
{
return cache_instance()->increment($key, $offset, $group);
return data_cache_instance()->increment($key, $offset, $group);
}
}

// ------------------------------------------------------------------------

if ( ! function_exists('cs_cache_decrement'))
if ( ! function_exists('data_cache_decrement'))
{
/**
* Dcrements numeric cache item's value.
Expand All @@ -745,15 +745,15 @@ function cs_cache_increment($key, $offset = 1, $group = '')
* @param string $group The group the key is in. Default 'default'.
* @return mixed the item's new value if decremented, else false.
*/
function cs_cache_decrement($key, $offset = 1, $group = '')
function data_cache_decrement($key, $offset = 1, $group = '')
{
return cache_instance()->decrement($key, $offset, $group);
return data_cache_instance()->decrement($key, $offset, $group);
}
}

// ------------------------------------------------------------------------

if ( ! function_exists('cs_cache_stats'))
if ( ! function_exists('data_cache_stats'))
{
/**
* Echoes the stats of the caching.
Expand All @@ -765,8 +765,8 @@ function cs_cache_decrement($key, $offset = 1, $group = '')
* @param none
* @return string
*/
function cs_cache_stats()
function data_cache_stats()
{
return cache_instance()->stats();
return data_cache_instance()->stats();
}
}

0 comments on commit 9c8c4aa

Please sign in to comment.