sarankk commented on code in PR #262:
URL: https://github.com/apache/cassandra-sidecar/pull/262#discussion_r2383627822
##########
server/src/main/java/org/apache/cassandra/sidecar/acl/AuthCache.java:
##########
@@ -119,13 +123,25 @@ public Map<K, V> getAll()
return Collections.unmodifiableMap(cache.asMap());
}
+ /**
+ * Invalidate a key.
+ * @param k key to invalidate
+ */
+ public void invalidate(K k)
+ {
+ if (cache != null)
+ {
+ cache.invalidate(k);
+ }
+ }
+
private LoadingCache<K, V> initCache()
{
return Caffeine.newBuilder()
- // setting refreshAfterWrite and expireAfterWrite to
same value makes sure no stale
- // data is fetched after expire time
-
.refreshAfterWrite(config.expireAfterAccess().quantity(),
config.expireAfterAccess().unit())
-
.expireAfterWrite(config.expireAfterAccess().quantity(),
config.expireAfterAccess().unit())
+ // The cache keeps the entry until it's last access has
expired. This avoids repeated calls to
+ // db for the same key during high volume requests.
+
.expireAfterAccess(config.expireAfterAccess().quantity(),
config.expireAfterAccess().unit())
Review Comment:
It could be beneficial to allow configuring both with different config
values, for removing stale entries. earlier we were using same config value for
both and behavior of that would be equivalent to having only refreshAfterWrite.
Instead shall I add one more config value to allow configuring
expireAfterAccess and refreshAfterWrite separately? @yifan-c
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]