Verified Commit 8cb8e467 authored by Camil Staps's avatar Camil Staps 🚀

Reload cache in background to not block the server

parent 6a5dbf38
Subproject commit dda194909330c588b35518672e9413149b92f9d9
Subproject commit 21cd481ed97688de862c2ef0f6b9341451c8be5c
......@@ -4,7 +4,7 @@ import StdArray
import StdBool
import StdFile
from StdFunc import id, o, seq
from StdMisc import undef
import StdMisc
import StdOrdList
import StdOverloaded
import StdTuple
......@@ -116,7 +116,7 @@ Start w
#! (_,f,w) = fopen "types.json" FReadText w
#! (db,f) = openDb f
#! db = hyperstrict db
#! w = if opts.reload_cache (reloadCache db) id w
#! w = if opts.reload_cache (doInBackground (reloadCache db)) id w
#! (_,w) = fclose f w
= serve
{ handler = handle db
......@@ -217,6 +217,13 @@ where
search :: !RequestCacheKey -> *World -> *World
search r = thd3 o handle db (Just $ fromRequestCacheKey r) o removeFromCache LongTerm r
doInBackground :: (*World -> *World) *World -> *World
doInBackground f w
#! (pid,w) = fork w
| pid < 0 = abort "fork failed\n"
| pid > 0 = w // Parent: return directly
| pid == 0 = f w // Child: do function
:: LogMemory =
{ mem_ip :: IPAddress
, mem_time_start :: Tm
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment