Warning: session_start(): open(/var/lib/php/sessions/sess_tu1lekvcpp5co9phf32os6tsdj, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
// only works within a module
// has mild race conditions
sclass SnippetInstaCache is AutoCloseable {
// snippet ID to text
SS texts = syncMap();
AutoCloseable updater;
*(S... snippetIDs) { this(asList(snippetIDs)); }
*(Iterable snippetIDs) {
updater = dm_onSnippetEdited(voidfunc(S id) {
bool contained = texts.containsKey(id);
print("SnippetInstaCache: snippet edited " + id + ", contained: " + contained);
if (contained)
texts.put(id, loadSnippet(id));
});
fOr (snippetID : map fsI(snippetIDs))
texts.put(snippetID, loadSnippet(snippetID));
}
// get snippet text
S get(S snippetID) {
ret texts.get(fsI(snippetID));
}
close { dispose updater; }
Cl cachedSnippetIDs() { ret cloneKeys(texts); }
}