yifan-c commented on code in PR #262:
URL: https://github.com/apache/cassandra-sidecar/pull/262#discussion_r2389323758
##########
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:
By configuring both and with the same value, the behavior is the same as
`expireAfterAccess`. Not equivalent to `refreshAfterWrite`. Given that the
configuration already declares `expire_after_access`, to not break the
compatibility, I would suggest to add a new configuration field
`refresh_after_write` and encourage to only configure `refresh_after_write` in
the document.
--
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]