diff --git a/code/common/getter.q b/code/common/getter.q new file mode 100644 index 000000000..71744a46b --- /dev/null +++ b/code/common/getter.q @@ -0,0 +1,28 @@ +// Bootstrap script that will enable an existing process to load in cache getter functionalities. + +\d .getter + +// Get cache from disk +getcachefromdisk:{[filepath] get hsym filepath} + +// Get location of cache config and load it in. +cacheconfiglocation:.proc.getconfigfile["cacheconfig.json"]; +cacheconfig:.j.k raze read0 hsym first cacheconfiglocation; +cachename: cacheconfig`cachename; +asyncprocessname: cacheconfig`asyncprocessname; + +loadcaches:{ + caches:key cacheconfig`componentcaches; + cachefilepaths: ` sv' ((hsym `$cacheconfig`cacherootdir),2#`$cachename),/:`$(string caches),\:"/data"; + cachesdata:getcachefromdisk each cachefilepaths; + cachevarnames:` sv' `.anycache.cache,/:caches; + cachevarnames set' cachesdata; +} + +// Example of args: `cache1`cache2!(`a`b`c! 1 2 3;`d`e`f!4 5 6) +requestnewcache:{[args] + maincache:` sv (hsym `$cacheconfig`cacherootdir),(`$cachename),`$asyncprocessname, "_", string .z.P; + (` sv maincache,`args) set args +} + +\d . \ No newline at end of file diff --git a/config/cacheconfig.json b/config/cacheconfig.json new file mode 100644 index 000000000..4c20947a2 --- /dev/null +++ b/config/cacheconfig.json @@ -0,0 +1,23 @@ +{ + "cacherootdir": "opt/anycache", + "cachename": "MyFirstCache", + "asyncprocessname": "AsyncCache", + "componentcaches":{ + "cache1": { + "analytic": "analytic1", + "dataSource": "connection1" + }, + "cache2": { + "analytic": "analytic2", + "dataSource": "connection2" + } + }, + "getter":{ + "interval": "0D00:05" + }, + "setter":{ + "mode": "timer", + "interval": "0D00:30", + "compression": "16 3 0" + } +} \ No newline at end of file