summaryrefslogtreecommitdiffstats
path: root/application/helpers/filebin_helper.php
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2015-04-02 17:21:19 +0200
committerFlorian Pritz <bluewind@xinu.at>2015-04-02 17:21:19 +0200
commit648e3cb5d45fe2a1318b3115439b5e64afa45ed9 (patch)
tree12c1a50b9eb84e52b476bdabf333e0cb62685802 /application/helpers/filebin_helper.php
parent601bd43a24f88f8f0e129743e7bc0b0d64eac887 (diff)
helper: Add cache_function_full
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/helpers/filebin_helper.php')
-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);