Implemented query cache size limit in front-end and in logic, Reworked LRUCache for performance, Fixed updating entities from front-end not working
This commit is contained in:
@@ -55,6 +55,10 @@ public class SearchdomainController : ControllerBase
|
||||
{
|
||||
try
|
||||
{
|
||||
if (settings.QueryCacheSize <= 0)
|
||||
{
|
||||
settings.QueryCacheSize = 1_000_000; // TODO get rid of this magic number
|
||||
}
|
||||
int id = _domainManager.CreateSearchdomain(searchdomain, settings);
|
||||
return Ok(new SearchdomainCreateResults(){Id = id, Success = true});
|
||||
} catch (Exception)
|
||||
@@ -255,7 +259,7 @@ public class SearchdomainController : ControllerBase
|
||||
}
|
||||
(Searchdomain? searchdomain_, int? httpStatusCode, string? message) = SearchdomainHelper.TryGetSearchdomain(_domainManager, searchdomain, _logger);
|
||||
if (searchdomain_ is null || httpStatusCode is not null) return StatusCode(httpStatusCode ?? 500, new SearchdomainUpdateResults(){Success = false, Message = message});
|
||||
int elementCount = searchdomain_.queryCache.Count();
|
||||
int elementCount = searchdomain_.queryCache.Count;
|
||||
int ElementMaxCount = searchdomain_.settings.QueryCacheSize;
|
||||
return Ok(new SearchdomainQueryCacheSizeResults() { SizeBytes = searchdomain_.GetSearchCacheSize(), ElementCount = elementCount, ElementMaxCount = ElementMaxCount, Success = true });
|
||||
}
|
||||
|
||||
@@ -91,4 +91,10 @@ public static class DatabaseMigrations
|
||||
helper.ExecuteSQLNonQuery("ALTER TABLE datapoint ADD COLUMN similaritymethod VARCHAR(512) NULL DEFAULT 'Cosine' AFTER probmethod_embedding", []);
|
||||
return 4;
|
||||
}
|
||||
|
||||
public static int UpdateFrom4(SQLHelper helper)
|
||||
{
|
||||
helper.ExecuteSQLNonQuery("UPDATE searchdomain SET settings = JSON_SET(settings, '$.QueryCacheSize', 1000000) WHERE JSON_EXTRACT(settings, '$.QueryCacheSize') is NULL;", []); // Set QueryCacheSize to a default of 1000000
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
@@ -887,12 +887,12 @@
|
||||
var data = [{
|
||||
"name": name,
|
||||
"probmethod": probMethod,
|
||||
"searchdomain": encodeURIComponent(domains[getSelectedDomainKey()]),
|
||||
"searchdomain": domains[getSelectedDomainKey()],
|
||||
"attributes": attributes,
|
||||
"datapoints": datapoints
|
||||
}];
|
||||
showToast("@T["Updating entity"]", "primary");
|
||||
fetch(`/Entity`, {
|
||||
fetch(`/Entities`, {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
@@ -1073,6 +1073,8 @@
|
||||
let configElementCachereconciliation = document.getElementById('searchdomainConfigCacheReconciliation');
|
||||
let configElementCacheSize = document.getElementById('searchdomainConfigQueryCacheSize');
|
||||
|
||||
showThrobber(document.querySelector('#searchdomainConfigQueryCacheSize'), true);
|
||||
showThrobber(document.querySelector('#searchdomainConfigCacheReconciliation'), true);
|
||||
let cacheUtilizationPromise = getSearchdomainCacheUtilization(getSelectedDomainKey());
|
||||
let databaseUtilizationPromise = getSearchdomainDatabaseUtilization(getSelectedDomainKey());
|
||||
|
||||
@@ -1114,6 +1116,7 @@
|
||||
});
|
||||
|
||||
searchdomainConfigPromise.then(searchdomainConfig => {
|
||||
hideThrobber(document.querySelector('#searchdomainConfigCacheReconciliation'), true);
|
||||
if (searchdomainConfig != null && searchdomainConfig.Settings != null)
|
||||
{
|
||||
configElementCacheSize.value = searchdomainConfig.Settings.QueryCacheSize;
|
||||
@@ -1126,6 +1129,7 @@
|
||||
}
|
||||
});
|
||||
cacheUtilizationPromise.then(cacheUtilization => {
|
||||
hideThrobber(document.querySelector('#searchdomainConfigQueryCacheSize'), true);
|
||||
if (cacheUtilization != null && cacheUtilization.SizeBytes != null)
|
||||
{
|
||||
document.querySelector('#cacheUtilization').innerText =
|
||||
@@ -1309,14 +1313,30 @@
|
||||
domainItem.classList.add('list-group-item-danger');
|
||||
}
|
||||
|
||||
function showThrobber(element = null) {
|
||||
function showThrobber(element = null, direct = false) {
|
||||
if (element == null) element = document;
|
||||
element.querySelector('.spinner').classList.remove('d-none');
|
||||
if (direct) {
|
||||
let spinner = document.createElement('div');
|
||||
spinner.classList.add('spinner');
|
||||
spinner.style.position = "absolute";
|
||||
spinner.style.marginTop = "0.5rem";
|
||||
spinner.style.marginLeft = "0.5rem";
|
||||
element.style.opacity = "0.25";
|
||||
element.parentElement.insertBefore(spinner, element);
|
||||
} else {
|
||||
element.querySelector('.spinner').classList.remove('d-none');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function hideThrobber(element = null) {
|
||||
function hideThrobber(element = null, direct = false) {
|
||||
if (element == null) element = document;
|
||||
element.querySelector('.spinner').classList.add('d-none');
|
||||
if (direct) {
|
||||
element.previousElementSibling.remove()
|
||||
element.style.opacity = "1";
|
||||
} else {
|
||||
element.querySelector('.spinner').classList.add('d-none');
|
||||
}
|
||||
}
|
||||
|
||||
function showEntityDetails(entity) {
|
||||
|
||||
Reference in New Issue
Block a user