diff options
Diffstat (limited to 'public/app/extends/Cache_service.php')
| -rw-r--r-- | public/app/extends/Cache_service.php | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/public/app/extends/Cache_service.php b/public/app/extends/Cache_service.php new file mode 100644 index 0000000..52311f3 --- /dev/null +++ b/public/app/extends/Cache_service.php @@ -0,0 +1,82 @@ +<?php +namespace app\extends; + +use app\models\cms\Course_model; +use app\models\admin\Privilege_model; + +/** Cache service + * ----------------------------------------------------------------------------- + * + * class that gathers common source-expensive queries + * and helps for performance optimization + * + * when forcing cache creation the following option is used: + * $options = PROXY_IGNORE_CACHE + * + */ +class Cache_service +{ + + public static function courses_struct( $options = 0 ) + { + return proxy( // cache-get courses + [\app\models\cms\Course_model::class, 'courses_struct'], + [], CACHE_ROOT_TTL, + $options + ); + } + + public static function files_attributes( $options = 0 ) + { + return proxy( + [\app\models\cms\Course_model::class, 'files'], + [], CACHE_ROOT_TTL, + $options + ); + } + + + public static function privileges_hierarchy( $options = 0 ) + { + return proxy( + [\app\models\admin\Privilege_model::class, 'privileges'], + [], CACHE_ROOT_TTL, + $options + ); + } + + public static function pages_list( $options = 0 ) + { + return proxy( + [\app\models\cms\Course_model::class, 'pages'], + [], CACHE_ROOT_TTL, + $options + ); + } + + + /** entity + * + * create and retrieve a cached array of some entity + * + * @param $entiry (string|method): method of the main CMS model + * NOTE: CRITICAL: method must exist in the main CMS model + */ + public static function entity( $entity, $options = 0 ) + { + $allowed_methods = [ // to make sure method existence + 'page', + 'course', + 'lesson', + ]; + + // TODO: needs testing before release + // return proxy( + // [\app\models\admin\Course_model::class, $entity], + // [], CACHE_ROOT_TTL, + // $options + // ); + } + + +}
\ No newline at end of file |
