diff options
| author | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-04-27 03:47:30 +0300 |
|---|---|---|
| committer | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-04-27 03:47:30 +0300 |
| commit | 059e0d95d0c28bc5060e87e146eaf7411f51bf90 (patch) | |
| tree | 7c21ac432f16dde2329a0d5954d70711eceb48e6 /public/app/extends/Cache_service.php | |
| parent | 26cd8ee99659ef1926c96a049c93645ffc9b169d (diff) | |
| download | gyraf1gov-059e0d95d0c28bc5060e87e146eaf7411f51bf90.tar.gz gyraf1gov-059e0d95d0c28bc5060e87e146eaf7411f51bf90.tar.bz2 gyraf1gov-059e0d95d0c28bc5060e87e146eaf7411f51bf90.zip | |
skeleton commit; based on an anom project
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 |
