Change the location of the functions for working with the cache

This commit is contained in:
Valentin Popov 2018-02-18 21:28:46 +04:00
parent 53c49b69de
commit ebf76795da
2 changed files with 44 additions and 34 deletions

34
lib.php
View File

@ -44,40 +44,6 @@ function local_webhooks_change_status($serviceid) {
return $result;
}
/**
* Get data from the cache by key.
*
* @param string $eventname
* @return array
*/
function local_webhooks_cache_get($eventname) {
$cache = cache::make("local_webhooks", "webhooks_services");
return $cache->get($eventname);
}
/**
* Update the data in the cache by key.
*
* @param string $eventname
* @param array $recordlist
* @return boolean
*/
function local_webhooks_cache_set($eventname, $recordlist = array()) {
$cache = cache::make("local_webhooks", "webhooks_services");
return $cache->set($eventname, $recordlist);
}
/**
* Delete the data in the cache by key.
*
* @param string $eventname
* @return boolean
*/
function local_webhooks_cache_delete($eventname) {
$cache = cache::make("local_webhooks", "webhooks_services");
return $cache->delete($eventname);
}
/**
* Get the record from the database.
*

View File

@ -24,6 +24,50 @@
defined("MOODLE_INTERNAL") || die();
/**
* Get data from the cache by key.
*
* @param string $eventname
* @return array
*/
function local_webhooks_cache_get($eventname) {
$cache = cache::make("local_webhooks", "webhooks_services");
return $cache->get($eventname);
}
/**
* Update the data in the cache by key.
*
* @param string $eventname
* @param array $recordlist
* @return boolean
*/
function local_webhooks_cache_set($eventname, $recordlist = array()) {
$cache = cache::make("local_webhooks", "webhooks_services");
return $cache->set($eventname, $recordlist);
}
/**
* Delete the data in the cache by key.
*
* @param string $eventname
* @return boolean
*/
function local_webhooks_cache_delete($eventname) {
$cache = cache::make("local_webhooks", "webhooks_services");
return $cache->delete($eventname);
}
/**
* Clear the cache of the plugin.
*
* @return boolean
*/
function local_webhooks_cache_delete_all() {
$cache = cache::make("local_webhooks", "webhooks_services");
return $cache->purge();
}
/**
* Description of functions of the call of events
*