Skip to content

Commit bdd5b35

Browse files
committed
blobcity/db #5 Restore feature flag for query result caching
1 parent f004aad commit bdd5b35

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

engine/src/main/java/com/blobcity/db/features/FeatureRules.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public class FeatureRules {
2626
/**
2727
* Default configuration that is used
2828
*/
29+
public static boolean QUERY_RESULT_CACHING = true;
2930
public static boolean DATA_CACHING = false; // enable when stable
3031
public static boolean INDEX_CACHING = false; // enable when stable
3132
public static boolean CACHE_INSERTS = false; // enable when stable, move this somewhere else as this is a user preference and not license setting.

engine/src/main/java/com/blobcity/db/sql/statements/SelectExecutor.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.blobcity.db.bsql.BSqlCollectionManager;
2222
import com.blobcity.db.bsql.BSqlIndexManager;
2323
import com.blobcity.db.cache.QueryResultCache;
24+
import com.blobcity.db.features.FeatureRules;
2425
import com.blobcity.db.lang.columntypes.FieldType;
2526
import com.blobcity.db.schema.beans.SchemaManager;
2627
import com.blobcity.db.schema.beans.SchemaStore;
@@ -138,10 +139,12 @@ private String select(final String appId, CursorNode node, final String sqlStrin
138139
}
139140

140141
/* Load query result from cache if present in cache */
141-
final String result = queryResultCache.get(sqlString);
142-
if(result != null) {
143-
logger.trace("Returning cached response for SQL query: " + sqlString);
144-
return result;
142+
if(FeatureRules.QUERY_RESULT_CACHING) {
143+
final String result = queryResultCache.get(sqlString);
144+
if (result != null) {
145+
logger.trace("Returning cached response for SQL query: " + sqlString);
146+
return result;
147+
}
145148
}
146149

147150
String schema = selectNode.getFromList().get(0).getTableName().getSchemaName();
@@ -356,7 +359,10 @@ private String produceResult(final String ds, final String collection, final Str
356359
.put(BQueryParameters.PAYLOAD, result)
357360
.put(BQueryParameters.TIME, executionTime)
358361
.put(BQueryParameters.ROWS, result.size()).toString();
359-
queryResultCache.cache(ds, collection, sqlQuery, resultString);
362+
363+
if(FeatureRules.QUERY_RESULT_CACHING) {
364+
queryResultCache.cache(ds, collection, sqlQuery, resultString);
365+
}
360366

361367
/* Register the number of rows selected for cloud billing purposes */
362368
if(!ds.equals(".systemdb")) {

0 commit comments

Comments
 (0)