Skip to content
Snippets Groups Projects
Verified Commit bd13c749 authored by Timm Fitschen's avatar Timm Fitschen
Browse files

MAINT: deactivate user-specific query caches

parent c9af5f9b
No related branches found
No related tags found
1 merge request!65F permission checks
Pipeline #26597 passed
......@@ -30,8 +30,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
* Minimal changes to the error messages for invalid user names and passwords.
* Java query cache is now user specific when necessary. Thus, also more complex
queries are cached than before.
### Deprecated
......
......@@ -701,7 +701,8 @@ public class Query implements QueryInterface, ToElementable, TransactionInterfac
*/
private void getResultFromCache() {
// try key with username and realm
this.resultSet = getCached(getCacheKey(true));
// TODO include this again to activate the user-specific caching
// this.resultSet = getCached(getCacheKey(true));
if (this.resultSet == null) {
// try key without username and realm
this.resultSet = getCached(getCacheKey(false));
......@@ -712,7 +713,8 @@ public class Query implements QueryInterface, ToElementable, TransactionInterfac
// Decide whether user specific cache needs to be used or not
// Currently, this is solely determined via filteredIntermediateResult.
if (this.filteredIntermediateResult) {
cacheItem(getCacheKey(true), this.resultSet);
// TODO include this again to activate user-specific caching
// cacheItem(getCacheKey(true), this.resultSet);
} else {
cacheItem(getCacheKey(false), this.resultSet);
}
......@@ -774,7 +776,7 @@ public class Query implements QueryInterface, ToElementable, TransactionInterfac
cache.clear();
}
/** There are internal Entities (with ID<100) that should never be returned * */
/** There are internal Entities (with ID<100) that should never be returned. */
private List<IdVersionAclTriplet> removeInternalEntitiesFromResultSet() {
final List<IdVersionAclTriplet> filtered = new ArrayList<>();
......@@ -932,9 +934,6 @@ public class Query implements QueryInterface, ToElementable, TransactionInterfac
final long t1 = System.currentTimeMillis();
final IdVersionAclTriplet triplet = entityIterator.next();
if (triplet.id <= 99) {
continue;
}
if (!acl_cache.containsKey(triplet.acl)) {
acl_cache.put(
......@@ -1105,23 +1104,26 @@ public class Query implements QueryInterface, ToElementable, TransactionInterfac
String getCacheKey(boolean addUser) {
final StringBuilder sb = new StringBuilder();
if (addUser && (this.user != null)) {
sb.append("U_");
String principal_desc =
((Principal) this.user.getPrincipal()).getUsername()
+ Principal.REALM_SEPARATOR
+ ((Principal) this.user.getPrincipal()).getRealm()
+ Principal.REALM_SEPARATOR;
+ ((Principal) this.user.getPrincipal()).getRealm();
sb.append(principal_desc);
}
if (this.versioned) {
sb.append("versioned");
sb.append("V_");
}
if (this.role != null) {
sb.append("R_");
sb.append(this.role.toString());
}
if (this.entity != null) {
sb.append("E_");
sb.append(this.entity.toString());
}
if (this.filter != null) {
sb.append("F_");
sb.append(this.filter.getCacheKey());
}
return sb.toString();
......
......@@ -61,34 +61,36 @@ public class QueryTest {
@Test
public void testGetKey() {
assertEquals("enamePOV(pname,=,val1)", getCacheKey("FIND ename WITH pname = val1"));
assertEquals("enamePOV(pname,=,val1)", getCacheKey("COUNT ename WITH pname = val1"));
assertEquals("enamePOV(pname,=,val1)", getCacheKey("SELECT bla FROM ename WITH pname = val1"));
assertEquals("enamePOV(pname,null,null)", getCacheKey("SELECT bla FROM ename WITH pname"));
assertEquals("E_enameF_POV(pname,=,val1)", getCacheKey("FIND ename WITH pname = val1"));
assertEquals("E_enameF_POV(pname,=,val1)", getCacheKey("COUNT ename WITH pname = val1"));
assertEquals(
"enamemaxPOV(pname,null,null)",
"E_enameF_POV(pname,=,val1)", getCacheKey("SELECT bla FROM ename WITH pname = val1"));
assertEquals("E_enameF_POV(pname,null,null)", getCacheKey("SELECT bla FROM ename WITH pname"));
assertEquals(
"E_enameF_maxPOV(pname,null,null)",
getCacheKey("SELECT bla FROM ename WITH THE GREATEST pname"));
assertEquals(
"RECORDenamePOV(pname,=,val1)", getCacheKey("FIND RECORD ename WITH pname = val1"));
assertEquals("ENTITYPOV(pname,=,val1)", getCacheKey("COUNT ENTITY WITH pname = val1"));
"R_RECORDE_enameF_POV(pname,=,val1)", getCacheKey("FIND RECORD ename WITH pname = val1"));
assertEquals("R_ENTITYF_POV(pname,=,val1)", getCacheKey("COUNT ENTITY WITH pname = val1"));
assertEquals(
"enameConj(POV(pname,=,val1)POV(ename2,=,val2))",
"E_enameF_Conj(POV(pname,=,val1)POV(ename2,=,val2))",
getCacheKey("SELECT bla FROM ename WITH pname = val1 AND ename2 = val2"));
assertEquals("versionedENTITYID(,>,2)", getCacheKey("FIND ANY VERSION OF ENTITY WITH ID > 2"));
assertEquals("ENTITYID(min,,)", getCacheKey("FIND ENTITY WITH THE SMALLEST ID"));
assertEquals("ENTITYSAT(asdf/%%)", getCacheKey("FIND ENTITY WHICH IS STORED AT /asdf/*"));
assertEquals("ENTITYSAT(asdf/asdf)", getCacheKey("FIND ENTITY WHICH IS STORED AT asdf/asdf"));
assertEquals("V_R_ENTITYF_ID(,>,2)", getCacheKey("FIND ANY VERSION OF ENTITY WITH ID > 2"));
assertEquals("R_ENTITYF_ID(min,,)", getCacheKey("FIND ENTITY WITH THE SMALLEST ID"));
assertEquals("R_ENTITYF_SAT(asdf/%%)", getCacheKey("FIND ENTITY WHICH IS STORED AT /asdf/*"));
assertEquals(
"R_ENTITYF_SAT(asdf/asdf)", getCacheKey("FIND ENTITY WHICH IS STORED AT asdf/asdf"));
assertEquals(
"enamePOV(ref1,null,null)SUB(POV(pname,>,val1)",
"E_enameF_POV(ref1,null,null)SUB(POV(pname,>,val1)",
getCacheKey("FIND ename WITH ref1 WITH pname > val1 "));
assertEquals(
"ename@(ref1,null)SUB(POV(pname,>,val1)",
"E_enameF_@(ref1,null)SUB(POV(pname,>,val1)",
getCacheKey("FIND ename WHICH IS REFERENCED BY ref1 WITH pname > val1 "));
assertEquals(
"anonymous@anonymous@enamePOV(pname,=,val1)",
"U_anonymous@anonymousE_enameF_POV(pname,=,val1)",
getCacheKeyWithUser("FIND ename WITH pname = val1"));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment