diff options
author | Max Kostikov <max@kostikov.co> | 2021-01-20 22:18:27 +0100 |
---|---|---|
committer | Max Kostikov <max@kostikov.co> | 2021-01-20 22:18:27 +0100 |
commit | 491dffd9b734c1f7aa879cca6e48eae5dc7b3f03 (patch) | |
tree | c2bc40cbc0cab0f58726acfe70787c0ec73db1dd /Zotlabs | |
parent | ad42890a0b32f612a2161366ad63ef0759de84da (diff) | |
download | volse-hubzilla-491dffd9b734c1f7aa879cca6e48eae5dc7b3f03.tar.gz volse-hubzilla-491dffd9b734c1f7aa879cca6e48eae5dc7b3f03.tar.bz2 volse-hubzilla-491dffd9b734c1f7aa879cca6e48eae5dc7b3f03.zip |
Implement SQL query background caching
Diffstat (limited to 'Zotlabs')
-rw-r--r-- | Zotlabs/Daemon/Cache_query.php | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/Zotlabs/Daemon/Cache_query.php b/Zotlabs/Daemon/Cache_query.php new file mode 100644 index 000000000..c709c96b5 --- /dev/null +++ b/Zotlabs/Daemon/Cache_query.php @@ -0,0 +1,34 @@ +<?php + +namespace Zotlabs\Daemon; + +use Zotlabs\Lib\Cache; + +class Cache_query { + + static public function run($argc, $argv) { + + if(! $argc == 3) + return; + + $key = $argv[1]; + + $pid = get_config('procid', $key, false); + if ($pid && (function_exists('posix_kill') ? posix_kill($pid, 0) : true)) { + logger($key . ': procedure already run with pid ' . $pid); + return; + } + + $pid = getmypid(); + set_config('procid', $key, $pid); + + array_shift($argv); + array_shift($argv); + + $r = call_user_func_array('q', $argv); + if($r) + Cache::set($key, serialize($r)); + + del_config('procid', $key); + } +} |