Warning: session_start(): open(/var/lib/php/sessions/sess_ihg4jq6fjpdechlncpifap6m43, 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
!7
sclass Entry {
S code, hints;
transient F1 function;
transient Throwable error;
transient Map cache = syncMRUCache(1000);
}
set flag DynModule.
cmodule FunctionsOnStrings > DynObjectTable {
transient ReliableSingleThread rstUpdateListLater = dm_rstWithDelay(this, r fireDataChanged, 10.0);
start {
itemToMap = func(Entry e) -> Map {
litorderedmap(Code := e.code, Hints := nullIfEmpty(e.hints),
Loaded := e.function != null,
Error := strOrNull(e.error),
"Cache Size" := l(e.cache) + "/" + mruCacheSize(e.cache))
};
}
// API
F1 getFunction(S code, S hints) {
lock lock;
Entry e = objectWhere(data(), +code, +hints);
if (e == null) add(e = nu Entry(+code, +hints));
if (e.error != null) throw rethrow(e.error);
if (e.function == null) {
print("Loading function: " + code);
try {
final F1 f = codeWithHintsToFunctionOnString(code);
e.function = func(S s) -> O {
if (s == null) null;
O o = e.cache.get(s);
if (o == null) {
e.cache.put(s, o = callF(f, s));
rstUpdateListLater.trigger();
}
ret o;
};
fireDataChanged();
} catch ex {
e.error = ex;
fireDataChanged();
throw rethrow(ex);
}
}
ret e.function;
}
}