diff options
author | Mario <mario@mariovavti.com> | 2021-01-21 09:08:53 +0100 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2021-01-21 09:08:53 +0100 |
commit | fe97b63e0b227b2702f661490424b1e12c06f73a (patch) | |
tree | 726e97ed7ec587ee54e37da91b86946725047168 /Zotlabs/Daemon/Cache_query.php | |
parent | bdd6d878f1d83c1cc7b84ead5e171bf2c3a73b7c (diff) | |
parent | 3836e75c89573baca6b029a5fd36401696b86e8d (diff) | |
download | volse-hubzilla-fe97b63e0b227b2702f661490424b1e12c06f73a.tar.gz volse-hubzilla-fe97b63e0b227b2702f661490424b1e12c06f73a.tar.bz2 volse-hubzilla-fe97b63e0b227b2702f661490424b1e12c06f73a.zip |
Merge branch 'dev' into 'dev'
Implement SQL query background caching
See merge request hubzilla/core!1894
Diffstat (limited to 'Zotlabs/Daemon/Cache_query.php')
-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..18d19cdf2 --- /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, LOGGER_DEBUG); + 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); + } +} |