Added constants to the cache

Signed-off-by: Valentin Popov <info@valentineus.link>
This commit is contained in:
Valentin Popov 2018-03-12 14:20:30 +04:00
parent cce50b316d
commit e0a43273a3
Signed by: Valentin Popov
GPG Key ID: 269A00ACA90A8EA3

View File

@ -24,6 +24,9 @@
defined("MOODLE_INTERNAL") || die(); defined("MOODLE_INTERNAL") || die();
define("LOCAL_WEBHOOKS_NAME_CACHE_REPOSITORY", "webhooks_services");
define("LOCAL_WEBHOOKS_NAME_PLUGIN", "local_webhooks");
/** /**
* Get data from the cache by key. * Get data from the cache by key.
* *
@ -31,7 +34,7 @@ defined("MOODLE_INTERNAL") || die();
* @return array * @return array
*/ */
function local_webhooks_cache_get($eventname) { function local_webhooks_cache_get($eventname) {
$cache = cache::make("local_webhooks", "webhooks_services"); $cache = cache::make(LOCAL_WEBHOOKS_NAME_PLUGIN, LOCAL_WEBHOOKS_NAME_CACHE_REPOSITORY);
return $cache->get($eventname); return $cache->get($eventname);
} }
@ -43,7 +46,7 @@ function local_webhooks_cache_get($eventname) {
* @return boolean * @return boolean
*/ */
function local_webhooks_cache_set($eventname, $recordlist = array()) { function local_webhooks_cache_set($eventname, $recordlist = array()) {
$cache = cache::make("local_webhooks", "webhooks_services"); $cache = cache::make(LOCAL_WEBHOOKS_NAME_PLUGIN, LOCAL_WEBHOOKS_NAME_CACHE_REPOSITORY);
return $cache->set($eventname, $recordlist); return $cache->set($eventname, $recordlist);
} }
@ -54,7 +57,7 @@ function local_webhooks_cache_set($eventname, $recordlist = array()) {
* @return boolean * @return boolean
*/ */
function local_webhooks_cache_delete($eventname) { function local_webhooks_cache_delete($eventname) {
$cache = cache::make("local_webhooks", "webhooks_services"); $cache = cache::make(LOCAL_WEBHOOKS_NAME_PLUGIN, LOCAL_WEBHOOKS_NAME_CACHE_REPOSITORY);
return $cache->delete($eventname); return $cache->delete($eventname);
} }
@ -64,7 +67,7 @@ function local_webhooks_cache_delete($eventname) {
* @return boolean * @return boolean
*/ */
function local_webhooks_cache_reset() { function local_webhooks_cache_reset() {
$cache = cache::make("local_webhooks", "webhooks_services"); $cache = cache::make(LOCAL_WEBHOOKS_NAME_PLUGIN, LOCAL_WEBHOOKS_NAME_CACHE_REPOSITORY);
return $cache->purge(); return $cache->purge();
} }