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 is sent through without HTML Escaping via | safe #}
|
||||||
{{ html_content | safe }}
|
{{ html_content | safe }}
|
||||||
|
|
||||||
{% cache 604800 sidebar the_page.hash %}
|
{% cache 604800 sidebar page.file.digest %}
|
||||||
<section class="sidebar">
|
<section class="sidebar">
|
||||||
{% if backlinks|length > 0 %}
|
{% if backlinks|length > 0 %}
|
||||||
<div class="backlinks">
|
<div class="backlinks">
|
||||||
|
|
|
@ -17,11 +17,11 @@ def cache(key_prefix="", cache_connection="default", expire_secs=600):
|
||||||
|
|
||||||
ret = cache.get(cache_key)
|
ret = cache.get(cache_key)
|
||||||
if ret is None:
|
if ret is None:
|
||||||
logger.debug("cache_miss")
|
logger.debug(f"cache_miss {cache_key}")
|
||||||
ret = func(*args, **kwargs)
|
ret = func(*args, **kwargs)
|
||||||
cache.set(cache_key, ret, expire_secs)
|
cache.set(cache_key, ret, expire_secs)
|
||||||
else:
|
else:
|
||||||
logger.debug("cache_hit")
|
logger.debug(f"cache_hit {cache_key}")
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
{# HTML is sent through without HTML Escaping via | safe #}
|
{# HTML is sent through without HTML Escaping via | safe #}
|
||||||
{{ html_content | safe }}
|
{{ html_content | safe }}
|
||||||
|
|
||||||
{% cache 604800 sidebar the_page.hash %}
|
{% cache 604800 sidebar page.file.digest %}
|
||||||
<section class="sidebar">
|
<section class="sidebar">
|
||||||
{% if backlinks|length > 0 %}
|
{% if backlinks|length > 0 %}
|
||||||
<div class="backlinks">
|
<div class="backlinks">
|
||||||
|
|
|
@ -42,7 +42,9 @@ let
|
||||||
ARCOLOGY_ALLOWED_HOSTS = concatStringsSep "," cfg.domains;
|
ARCOLOGY_ALLOWED_HOSTS = concatStringsSep "," cfg.domains;
|
||||||
|
|
||||||
ARCOLOGY_LOG_LEVEL = cfg.logLevel;
|
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}";
|
GUNICORN_CMD_ARGS = "--bind=${cfg.address}:${toString cfg.port} -w ${toString cfg.workerCount}";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -52,6 +54,9 @@ let
|
||||||
system.activationScripts.arcology-collectfiles.text = ''
|
system.activationScripts.arcology-collectfiles.text = ''
|
||||||
echo "Setting up Arcology static files"
|
echo "Setting up Arcology static files"
|
||||||
ARCOLOGY_STATIC_ROOT=${cfg.staticRoot} ${cfg.packages.arcology}/bin/arcology collectstatic --no-input -c -v0
|
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 = {
|
systemd.services.arcology2-watchsync = {
|
||||||
description = "Arcology Django Syncthing Watcher";
|
description = "Arcology Django Syncthing Watcher";
|
||||||
|
@ -231,6 +236,24 @@ in {
|
||||||
Syncthing folder ID containing the org files.
|
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"
|
readme = "README.md"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"django ~= 4.2", "django-stub", "django-prometheus",
|
"django ~= 4.2", "django-stub", "django-prometheus",
|
||||||
"click ~=8.1", "polling", "arrow ~= 1.3.0", "gunicorn ~= 21.0", "htmx ~= 1.17"
|
"click ~=8.1", "polling", "arrow ~= 1.3.0", "gunicorn ~= 21.0", "htmx ~= 1.17",
|
||||||
"arroyo",
|
"arroyo"
|
||||||
]
|
]
|
||||||
requires-python = ">=3.10"
|
requires-python = ">=3.10"
|
||||||
authors = [
|
authors = [
|
||||||
|
|
|
@ -20,8 +20,8 @@ description = "org-mode metadata query engine, publishing platform, and computer
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"django ~= 4.2", "django-stub", "django-prometheus",
|
"django ~= 4.2", "django-stub", "django-prometheus",
|
||||||
"click ~=8.1", "polling", "arrow ~= 1.3.0", "gunicorn ~= 21.0", "htmx ~= 1.17"
|
"click ~=8.1", "polling", "arrow ~= 1.3.0", "gunicorn ~= 21.0", "htmx ~= 1.17",
|
||||||
"arroyo",
|
"arroyo"
|
||||||
]
|
]
|
||||||
requires-python = ">=3.10"
|
requires-python = ">=3.10"
|
||||||
authors = [
|
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:
|
So now you can do this:
|
||||||
|
|
||||||
#+begin_src python
|
#+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):
|
def gimme(hk):
|
||||||
return "hello, world!"
|
return "hello, world!"
|
||||||
|
|
||||||
|
@ -464,11 +464,11 @@ def cache(key_prefix="", cache_connection="default", expire_secs=600):
|
||||||
|
|
||||||
ret = cache.get(cache_key)
|
ret = cache.get(cache_key)
|
||||||
if ret is None:
|
if ret is None:
|
||||||
logger.debug("cache_miss")
|
logger.debug(f"cache_miss {cache_key}")
|
||||||
ret = func(*args, **kwargs)
|
ret = func(*args, **kwargs)
|
||||||
cache.set(cache_key, ret, expire_secs)
|
cache.set(cache_key, ret, expire_secs)
|
||||||
else:
|
else:
|
||||||
logger.debug("cache_hit")
|
logger.debug(f"cache_hit {cache_key}")
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
Loading…
Reference in New Issue