Skip to content
New issue

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

When using method level cache, no matter what i config, it's always LruCache. #1362

Closed
zhaojigang opened this issue Feb 10, 2018 · 8 comments · Fixed by #1396
Closed

When using method level cache, no matter what i config, it's always LruCache. #1362

zhaojigang opened this issue Feb 10, 2018 · 8 comments · Fixed by #1396
Labels
type/bug Bugs to being fixed

Comments

@zhaojigang
Copy link
Contributor

zhaojigang commented Feb 10, 2018

consumer配置:
<dubbo:reference id="demoService" check="false" interface="com.alibaba.dubbo.demo.DemoService">
<dubbo:method name="sayHello" timeout="60000" cache="threadlocal"/>
</dubbo:reference>

在执行的过程中,我们发现其实并不会创建ThreadlocalCache,而是用的LruCache,原因是在
image
可以看到,当将cache配置在方法上而不是服务上的时候,传入的url只有"method.cache"参数而没有"cache"参数,但是CacheFactory$Adaptive这个类并没有作区分。

@kimmking
Copy link
Member

kimmking commented Feb 10, 2018

it seems a bug

@hqq2023623
Copy link
Contributor

有几个疑问:
1、dubbo分支或者版本是多少
2、CacheFactory$Adaptive这个类是你们自己写的吗,在dubbo源码里没看到
3、如果是自己写的,按照图里的代码创建的就应该是作为默认值的LruCache,原因如你所说没有cache这个key,你可以自己适配cache的key
4、看你的问题的话应该是期望在Reference和Method两层都配置cache的话应该统一的key是“cache",那如果我希望Reference中不同的Method使用不同的cache该如何处理呢?
5、URL参数的设置可以在ReferenceConfig#init()方法查看
@zhaojigang

@zhaojigang
Copy link
Contributor Author

1、当前master分支
2、CacheFactory$Adaptive是自适应生成的类
3、不是自己写的
4、不是这个期望,你理解错误了
@hqq2023623

@zhaojigang
Copy link
Contributor Author

嗯,麻烦官方看一下,应该是个bug @kimmking

@chickenlj chickenlj changed the title 将cache配置为方法级别的时候,不管怎么配置只能创建LruCache When using method level cache, no matter what i config, it's always been LruCache. Feb 12, 2018
@chickenlj chickenlj changed the title When using method level cache, no matter what i config, it's always been LruCache. When using method level cache, no matter what i config, it's always LruCache. Feb 12, 2018
@chickenlj
Copy link
Contributor

@zhaojigang Would you like to create a PR?

@chickenlj chickenlj added the type/bug Bugs to being fixed label Feb 12, 2018
@kimmking
Copy link
Member

@zhaojigang
if you wanna create a pr to fix this issue,i can give you some help

@solayw
Copy link

solayw commented Feb 12, 2018

问题出在ExtensionLoader上, 在生成的代理类中,应该使用url.getMethodParameter而不是url.getParameter
具体由https://github.com/alibaba/dubbo/blob/master/dubbo-common/src/main/java/com/alibaba/dubbo/common/extension/ExtensionLoader.java#L832
hasInvocation 控制
谁能解释一下这个变量的作用什么

@maxiaoguang64
Copy link
Contributor

@kimmking I will fix it.

beiwei30 pushed a commit that referenced this issue Mar 5, 2018
* #1362修复

#1362修复

* #1362修复

#1362修复

* #1362修复

#1362修复

* 修改bug

修改bug

* 修改bug

修改bug

* 添加cache的测试用例

添加cache的测试用例
xpylq pushed a commit to xpylq/dubbo that referenced this issue Mar 5, 2018
* remotes/upstream/master: (226 commits)
  clean up imports for CacheTest
  [Dubbo-apache#1362] cache provider always lru cache (apache#1396)
  Remove author info and add apache license
  Fix "promoteTransitiveDependencies=false" of maven-shade-plugin
  apache#1411: Locale deserialize 'zh-hant_CN'
  update README format
  update readme to add some details (apache#1403)
  fix number type is lost in yaml config file (apache#1401)
  fix hessian lite test case fail bug (apache#1394)
  Merge pull request apache#1391, fix typo of method name in qos module.
  Fix time unit problem related with FutureAdapter in UT
  Fix time unit problem related with FutureAdapter in UT
  Fix time unit problem in UT
  Fixed apache#1398, revert bugs introduced from apache#1375
  Change Mailing list address
  Merge pull request apache#1242, remove redundant null check.
  Merge pull request apache#1040, refactor: replace some deprecated methods related with jedis.
  Merge pull request apache#1384, fix build string bug.
  Merge pull request apache#1376, do not instantiate load balance if there is no invokers
  Merge pull request apache#1331, add optional parameter to support hessian protocol method overload and request protocol version.
  ...
rolandhe pushed a commit to rolandhe/dubbo that referenced this issue Sep 9, 2019
* #1362修复

#1362修复

* #1362修复

#1362修复

* #1362修复

#1362修复

* 修改bug

修改bug

* 修改bug

修改bug

* 添加cache的测试用例

添加cache的测试用例
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Bugs to being fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants