You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuweni.apache.org by to...@apache.org on 2021/08/19 13:36:14 UTC
[incubator-tuweni] branch main updated: Add expiration and lifespan
config
This is an automated email from the ASF dual-hosted git repository.
toulmean pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-tuweni.git
The following commit(s) were added to refs/heads/main by this push:
new 00c1efc Add expiration and lifespan config
new ebde62c Merge pull request #339 from atoulme/add_expiration_and_lifespan
00c1efc is described below
commit 00c1efc4e99baf232d5a28147e8f1ee049040574
Author: Antoine Toulme <an...@lunar-ocean.com>
AuthorDate: Thu Aug 19 05:56:04 2021 -0700
Add expiration and lifespan config
---
.../src/main/kotlin/org/apache/tuweni/jsonrpc/app/JSONRPCApp.kt | 2 +-
.../src/main/kotlin/org/apache/tuweni/jsonrpc/app/JSONRPCConfig.kt | 4 ++++
.../main/kotlin/org/apache/tuweni/jsonrpc/methods/MethodsHandler.kt | 2 --
3 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/jsonrpc-app/src/main/kotlin/org/apache/tuweni/jsonrpc/app/JSONRPCApp.kt b/jsonrpc-app/src/main/kotlin/org/apache/tuweni/jsonrpc/app/JSONRPCApp.kt
index 7cf0a2c..7bd963a 100644
--- a/jsonrpc-app/src/main/kotlin/org/apache/tuweni/jsonrpc/app/JSONRPCApp.kt
+++ b/jsonrpc-app/src/main/kotlin/org/apache/tuweni/jsonrpc/app/JSONRPCApp.kt
@@ -133,7 +133,7 @@ class JSONRPCApplication(
"responses",
ConfigurationBuilder().persistence().addStore(RocksDBStoreConfigurationBuilder::class.java)
.location(Paths.get(config.cacheStoragePath(), "storage").toAbsolutePath().toString())
- .expiredLocation(Paths.get(config.cacheStoragePath(), "expired").toAbsolutePath().toString()).build()
+ .expiredLocation(Paths.get(config.cacheStoragePath(), "expired").toAbsolutePath().toString()).expiration().lifespan(config.cacheLifespan()).maxIdle(config.cacheMaxIdle()).build()
)
val cachingHandler =
diff --git a/jsonrpc-app/src/main/kotlin/org/apache/tuweni/jsonrpc/app/JSONRPCConfig.kt b/jsonrpc-app/src/main/kotlin/org/apache/tuweni/jsonrpc/app/JSONRPCConfig.kt
index 62917f8..1d8fd57 100644
--- a/jsonrpc-app/src/main/kotlin/org/apache/tuweni/jsonrpc/app/JSONRPCConfig.kt
+++ b/jsonrpc-app/src/main/kotlin/org/apache/tuweni/jsonrpc/app/JSONRPCConfig.kt
@@ -57,6 +57,8 @@ class JSONRPCConfig(val filePath: Path) {
.addInteger("maxConcurrentRequests", 30, "Maximum concurrent requests", null)
.addString("metricsGrpcEndpoint", "http://localhost:4317", "Metrics GRPC push endpoint", null)
.addLong("metricsGrpcTimeout", 2000, "Metrics GRPC push timeout", null)
+ .addLong("cacheLifespan", 5000, "Lifespan time for entries on cache in milliseconds", null)
+ .addLong("cacheMaxIdle", 1000, "Max idle time for entries on cache in milliseconds", null)
.toSchema()
}
@@ -91,4 +93,6 @@ class JSONRPCConfig(val filePath: Path) {
fun maxConcurrentRequests() = config.getInteger("maxConcurrentRequests")
fun metricsGrpcEndpoint() = config.getString("metricsGrpcEndpoint")
fun metricsGrpcTimeout() = config.getLong("metricsGrpcTimeout")
+ fun cacheLifespan() = config.getLong("cacheLifespan")
+ fun cacheMaxIdle() = config.getLong("cacheMaxIdle")
}
diff --git a/jsonrpc/src/main/kotlin/org/apache/tuweni/jsonrpc/methods/MethodsHandler.kt b/jsonrpc/src/main/kotlin/org/apache/tuweni/jsonrpc/methods/MethodsHandler.kt
index 1f55c19..b881d76 100644
--- a/jsonrpc/src/main/kotlin/org/apache/tuweni/jsonrpc/methods/MethodsHandler.kt
+++ b/jsonrpc/src/main/kotlin/org/apache/tuweni/jsonrpc/methods/MethodsHandler.kt
@@ -134,8 +134,6 @@ class CachingHandler(
newResponse
} else {
cacheHitCounter.add(1)
- // reset the expiry on the entry:
- cacheStore.put(serializedRequest, response)
response.copy(id = request.id)
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tuweni.apache.org
For additional commands, e-mail: commits-help@tuweni.apache.org