We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
下面的使用方式有 Surprise的感觉:
AviatorEvaluatorInstance
useLRUExpressionCache
use*ExpressionCache
execute
cached
true
上面可能问题的解决方法(API设计)是不是 可以下面的做法:
API
Class
如果上面的思路/解决方法觉得OK,我可以试着给个PR。:")
public class ExpressionCacheBehaviorSurpriseTest { @Test public void call_useLRUExpressionCache_butExpressionNotCached__SURPRISE() { final Map<String, Object> context = new HashMap<>(); context.put("var1", 10); context.put("var2", 20); final String expr = "var1 < 100 && var2 < 200"; // --> Have called *use*LRUExpressionCache final AviatorEvaluatorInstance instance = AviatorEvaluator.newInstance().useLRUExpressionCache(100); final Boolean result = (Boolean) instance.execute(expr, context); assertTrue(result); // --> But expression Not cached. SURPRISE! assertFalse(instance.isExpressionCached(expr)); } @Test public void shouldCall_useLRUExpressionCache_and_passCachedParameterToExecute_then_ExpressionWillCache() { final Map<String, Object> context = new HashMap<>(); context.put("var1", 10); context.put("var2", 20); final String expr = "var1 < 100 && var2 < 200"; // --> Have called *use*LRUExpressionCache final AviatorEvaluatorInstance instance = AviatorEvaluator.newInstance().useLRUExpressionCache(100); // --> And pass cached parameter to execute method final Boolean result = (Boolean) instance.execute(expr, context, true); assertTrue(result); // --> Then expression will cache assertTrue(instance.isExpressionCached(expr)); } }
PS: show case source file
The text was updated successfully, but these errors were encountered:
最终决定引入一个属性,类似 AviatorEvaluatorInstance#setExpressionCaching(boolean) 来设置是否开启全局缓存。
AviatorEvaluatorInstance#setExpressionCaching(boolean)
Sorry, something went wrong.
(feat) Adds AviatorEvaluatorInstance#setCachedExpressionByDefault(boo…
6dd2983
…lean), #330
5.2.2 发布 https://github.com/killme2008/aviatorscript/releases/tag/aviator-5.2.2
No branches or pull requests
下面的使用方式有 Surprise的感觉:
AviatorEvaluatorInstance
的useLRUExpressionCache
(use*ExpressionCache
)方法,但不会生效表达式缓存,有些surprise。
execute
方法)时,传递上cached
参数为true
,才生效表达式缓存。AviatorEvaluatorInstance
上有个缺省设置:AviatorEvaluatorInstance
级的设置。上面可能问题的解决方法(
API
设计)是不是 可以下面的做法:AviatorEvaluatorInstance
级,可以(缺省)设置『表达式是否缓存』useLRUExpressionCache
/use*ExpressionCache
方法,隐含了AviatorEvaluatorInstance
级『表达式要缓存』use*ExpressionCache
)的直觉,没有Surprise。AviatorEvaluatorInstance
级默认开启『表达式要缓存』? @killme2008Class
回收慢会压跨应用。如果上面的思路/解决方法觉得OK,我可以试着给个PR。:")
PS: show case source file
相关资料
The text was updated successfully, but these errors were encountered: