From 02608271bb2a9f3a65ed536984d306ee14b48e34 Mon Sep 17 00:00:00 2001 From: Geo Halkiadakis Date: Sun, 12 Jul 2026 15:51:52 +0300 Subject: initialize repository; add docker config; migrate configuration to new specs --- core/design_patterns.php | 104 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 core/design_patterns.php (limited to 'core/design_patterns.php') diff --git a/core/design_patterns.php b/core/design_patterns.php new file mode 100644 index 0000000..d66ffa9 --- /dev/null +++ b/core/design_patterns.php @@ -0,0 +1,104 @@ +get($key); + + } else { $data = false; } // ignore cache? pass false + + + if ($data !== false) { // if exists, serve cached data + + // if cashed data exist + // --------------------------------------------------------------------- + # if (!PRODUCTION) Benchmark::add_spot('proxy-cached'); + if ($data == '_ERROR_') return false; // previous cached error + else return $data; // previous cache () + + + } else { // else (not exist)... + + // no data on cache -> get data from Class::method( arguments ) + // --------------------------------------------------------------------- + $data = call_user_func_array($callable, $args); + + // handle newly created data + // --------------------------------------------------------------------- + + // if faulty data, return false + if ($data == false) { + + if ($cache_errors && !$do_not_cache) { // cache the error + $cache->set($key, '_ERROR_', $ttl); + } + + # if (!PRODUCTION) Benchmark::add_spot('proxy-new-error'); + return false; + } + + // store to cache + if (!$do_not_cache) { + $cache->set($key, $data, $ttl); + } + + # if (!PRODUCTION) Benchmark::add_spot('proxy-new'); + return $data; // serve data + } + +} -- cgit v1.2.3