Compare commits
3 Commits
22351ef1df
...
208a58e697
Author | SHA1 | Date |
---|---|---|
Ryan Rix | 208a58e697 | |
Ryan Rix | 7c44a3fa8f | |
Ryan Rix | 3101f957e1 |
|
@ -684,7 +684,7 @@ The main =content= block contains the =<main>= generated by the native parser, a
|
|||
{# HTML is sent through without HTML Escaping via | safe #}
|
||||
{{ html_content | safe }}
|
||||
|
||||
{% cache 604800 sidebar the_page.hash %}
|
||||
{% cache 604800 sidebar page.file.digest %}
|
||||
<section class="sidebar">
|
||||
{% if backlinks|length > 0 %}
|
||||
<div class="backlinks">
|
||||
|
|
|
@ -17,11 +17,11 @@ def cache(key_prefix="", cache_connection="default", expire_secs=600):
|
|||
|
||||
ret = cache.get(cache_key)
|
||||
if ret is None:
|
||||
logger.debug("cache_miss")
|
||||
logger.debug(f"cache_miss {cache_key}")
|
||||
ret = func(*args, **kwargs)
|
||||
cache.set(cache_key, ret, expire_secs)
|
||||
else:
|
||||
logger.debug("cache_hit")
|
||||
logger.debug(f"cache_hit {cache_key}")
|
||||
return ret
|
||||
|
||||
return wrapper
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
{# HTML is sent through without HTML Escaping via | safe #}
|
||||
{{ html_content | safe }}
|
||||
|
||||
{% cache 604800 sidebar the_page.hash %}
|
||||
{% cache 604800 sidebar page.file.digest %}
|
||||
<section class="sidebar">
|
||||
{% if backlinks|length > 0 %}
|
||||
<div class="backlinks">
|
||||
|
|
|
@ -42,7 +42,9 @@ let
|
|||
ARCOLOGY_ALLOWED_HOSTS = concatStringsSep "," cfg.domains;
|
||||
|
||||
ARCOLOGY_LOG_LEVEL = cfg.logLevel;
|
||||
ARCOLOGY_CACHE_PATH = cfg.cacheDir;
|
||||
|
||||
PROMETHEUS_MULTIPROC_DIR = cfg.multiProcDir;
|
||||
GUNICORN_CMD_ARGS = "--bind=${cfg.address}:${toString cfg.port} -w ${toString cfg.workerCount}";
|
||||
};
|
||||
|
||||
|
@ -52,6 +54,9 @@ let
|
|||
system.activationScripts.arcology-collectfiles.text = ''
|
||||
echo "Setting up Arcology static files"
|
||||
ARCOLOGY_STATIC_ROOT=${cfg.staticRoot} ${cfg.packages.arcology}/bin/arcology collectstatic --no-input -c -v0
|
||||
echo "Ensuring Arcology directories exist"
|
||||
mkdir -p ${cfg.dataDir} ${cfg.multiProcDir} ${cfg.cacheDir}
|
||||
chown arcology:arcology ${cfg.dataDir} ${cfg.multiProcDir} ${cfg.cacheDir}
|
||||
'';
|
||||
systemd.services.arcology2-watchsync = {
|
||||
description = "Arcology Django Syncthing Watcher";
|
||||
|
@ -231,6 +236,24 @@ in {
|
|||
Syncthing folder ID containing the org files.
|
||||
'';
|
||||
};
|
||||
|
||||
cacheDir = mkOption {
|
||||
type = types.path;
|
||||
default = "${cfg.dataDir}/cache/";
|
||||
description = mdDoc ''
|
||||
Location to cache HTML files and the like.
|
||||
'';
|
||||
};
|
||||
|
||||
multiProcDir = mkOption {
|
||||
type = types.path;
|
||||
default = "${cfg.dataDir}/metrics/";
|
||||
description = mdDoc ''
|
||||
Location where prometheus will cache metrics to be coalesced on all workers.
|
||||
|
||||
See https://github.com/korfuri/django-prometheus/blob/master/documentation/exports.md
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@ description = "org-mode metadata query engine, publishing platform, and computer
|
|||
readme = "README.md"
|
||||
dependencies = [
|
||||
"django ~= 4.2", "django-stub", "django-prometheus",
|
||||
"click ~=8.1", "polling", "arrow ~= 1.3.0", "gunicorn ~= 21.0", "htmx ~= 1.17"
|
||||
"arroyo",
|
||||
"click ~=8.1", "polling", "arrow ~= 1.3.0", "gunicorn ~= 21.0", "htmx ~= 1.17",
|
||||
"arroyo"
|
||||
]
|
||||
requires-python = ">=3.10"
|
||||
authors = [
|
||||
|
|
|
@ -20,8 +20,8 @@ description = "org-mode metadata query engine, publishing platform, and computer
|
|||
readme = "README.md"
|
||||
dependencies = [
|
||||
"django ~= 4.2", "django-stub", "django-prometheus",
|
||||
"click ~=8.1", "polling", "arrow ~= 1.3.0", "gunicorn ~= 21.0", "htmx ~= 1.17"
|
||||
"arroyo",
|
||||
"click ~=8.1", "polling", "arrow ~= 1.3.0", "gunicorn ~= 21.0", "htmx ~= 1.17",
|
||||
"arroyo"
|
||||
]
|
||||
requires-python = ">=3.10"
|
||||
authors = [
|
||||
|
@ -427,9 +427,9 @@ There are currently four invocations of =lru_cache= in this code-base they're al
|
|||
So now you can do this:
|
||||
|
||||
#+begin_src python
|
||||
import arcology.file_cache as fc
|
||||
from arcology.cache_decorator import cache
|
||||
|
||||
@fc.cache_string(cache_prefix="/tmp/strs")
|
||||
@cache(key_prefix="local_test")
|
||||
def gimme(hk):
|
||||
return "hello, world!"
|
||||
|
||||
|
@ -464,11 +464,11 @@ def cache(key_prefix="", cache_connection="default", expire_secs=600):
|
|||
|
||||
ret = cache.get(cache_key)
|
||||
if ret is None:
|
||||
logger.debug("cache_miss")
|
||||
logger.debug(f"cache_miss {cache_key}")
|
||||
ret = func(*args, **kwargs)
|
||||
cache.set(cache_key, ret, expire_secs)
|
||||
else:
|
||||
logger.debug("cache_hit")
|
||||
logger.debug(f"cache_hit {cache_key}")
|
||||
return ret
|
||||
|
||||
return wrapper
|
||||
|
|
Loading…
Reference in New Issue