From e0a43273a3b72d000623472208336cbb333b356a Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Mon, 12 Mar 2018 14:20:30 +0400 Subject: Added constants to the cache Signed-off-by: Valentin Popov --- locallib.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/locallib.php b/locallib.php index aac8c58..6ad80b6 100644 --- a/locallib.php +++ b/locallib.php @@ -24,6 +24,9 @@ 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. * @@ -31,7 +34,7 @@ defined("MOODLE_INTERNAL") || die(); * @return array */ 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); } @@ -43,7 +46,7 @@ function local_webhooks_cache_get($eventname) { * @return boolean */ 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); } @@ -54,7 +57,7 @@ function local_webhooks_cache_set($eventname, $recordlist = array()) { * @return boolean */ 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); } @@ -64,7 +67,7 @@ function local_webhooks_cache_delete($eventname) { * @return boolean */ 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(); } -- cgit v1.2.3