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. -- 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: issues-unsubscr...@struts.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org