[
https://issues.apache.org/jira/browse/WW-5355?focusedWorklogId=885495&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-885495
]
ASF GitHub Bot logged work on WW-5355:
--------------------------------------
Author: ASF GitHub Bot
Created on: 17/Oct/23 03:11
Start Date: 17/Oct/23 03:11
Worklog Time Spent: 10m
Work Description: kusalk commented on code in PR #766:
URL: https://github.com/apache/struts/pull/766#discussion_r1361461252
##########
core/src/main/java/com/opensymphony/xwork2/ognl/OgnlCacheFactory.java:
##########
@@ -19,12 +19,52 @@
* Used by {@link com.opensymphony.xwork2.ognl.OgnlUtil} to create appropriate
OGNL
* caches based on configuration.
*
- * @param <Key> The type for the cache key entries
+ * @param <Key> The type for the cache key entries
* @param <Value> The type for the cache value entries
*/
-interface OgnlCacheFactory<Key, Value> {
+public interface OgnlCacheFactory<Key, Value> {
OgnlCache<Key, Value> buildOgnlCache();
- OgnlCache<Key, Value> buildOgnlCache(int evictionLimit, int
initialCapacity, float loadFactor, boolean lruCache);
+
+ /**
+ * Note that if {@code lruCache} is {@code false}, the cache type could
still be LRU if the default cache type is
+ * configured as such.
+ * @deprecated since 6.4.0, use {@link #buildOgnlCache(int, int, float,
CacheType)}
+ */
+ @Deprecated
+ default OgnlCache<Key, Value> buildOgnlCache(int evictionLimit,
+ int initialCapacity,
+ float loadFactor,
+ boolean lruCache) {
+ return buildOgnlCache(evictionLimit,
+ initialCapacity,
+ loadFactor,
+ lruCache ? CacheType.SYNC_LINKED_LRU : getDefaultCacheType());
+ }
+
+ /**
+ * @param evictionLimit maximum capacity of the cache where applicable
for cache type chosen
+ * @param initialCapacity initial capacity of the cache where applicable
for cache type chosen
+ * @param loadFactor load factor of the cache where applicable for
cache type chosen
+ * @param cacheType type of cache to build
+ * @return a new cache instance
+ */
+ OgnlCache<Key, Value> buildOgnlCache(int evictionLimit, int
initialCapacity, float loadFactor, CacheType cacheType);
+
int getCacheMaxSize();
- boolean getUseLRUCache();
+
+ /**
+ * @deprecated since 6.4.0
+ */
+ @Deprecated
+ default boolean getUseLRUCache() {
+ return CacheType.SYNC_LINKED_LRU.equals(getDefaultCacheType());
+ }
+
+ CacheType getDefaultCacheType();
+
+ enum CacheType {
+ CONCURRENT_BASIC,
+ SYNC_LINKED_LRU,
+ CAFFEINE_WTLFU
Review Comment:
I was wondering the same thing - I was only maintaining the design
introduced in #528.
I simply replaced `struts.ognl.expressionCacheLRUMode=true|false` with
`struts.ognl.expressionCacheType=concurrent_basic|sync_linked_lru|caffeine_wtlfu`
Let me look into refactoring this, it will likely be a breaking change
though.
Issue Time Tracking
-------------------
Worklog Id: (was: 885495)
Time Spent: 6h (was: 5h 50m)
> Use LRU cache by default
> ------------------------
>
> Key: WW-5355
> URL: https://issues.apache.org/jira/browse/WW-5355
> Project: Struts 2
> Issue Type: Improvement
> Components: Core
> Reporter: Kusal Kithul-Godage
> Priority: Minor
> Fix For: 6.4.0
>
> Time Spent: 6h
> Remaining Estimate: 0h
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)