summaryrefslogtreecommitdiffstats
path: root/application/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'application/helpers')
-rw-r--r--application/helpers/filebin_helper.php19
1 files changed, 18 insertions, 1 deletions
diff --git a/application/helpers/filebin_helper.php b/application/helpers/filebin_helper.php
index 2604cfe4e..b5df4f877 100644
--- a/application/helpers/filebin_helper.php
+++ b/application/helpers/filebin_helper.php
@@ -283,7 +283,7 @@ function stateful_client()
}
/**
- * Cache the result of the function call
+ * Cache the result of the function call in the cache backend.
* @param key cache key to use
* @param ttl time to live for the cache entry
* @param function function to call
@@ -300,6 +300,23 @@ function cache_function($key, $ttl, $function)
return $content;
}
+/**
+ * Cache the result of a function call in the cache backend and in the memory of this process.
+ * @param key cache key to use
+ * @param ttl time to live for the cache entry
+ * @param function function to call
+ * @return return value of function (will be cached)
+ */
+function cache_function_full($key, $ttl, $function) {
+ $local_key = 'cache_function-'.$key;
+ if (static_storage($local_key) !== null) {
+ return static_storage($local_key);
+ }
+ $ret = cache_function($key, $ttl, $function);
+ static_storage($local_key, $ret);
+ return $ret;
+}
+
// Return mimetype of file
function mimetype($file) {
$fileinfo = new finfo(FILEINFO_MIME_TYPE);