{"id":36420481,"url":"https://github.com/bohrqiu/dubbo-cache","last_synced_at":"2026-01-11T17:32:25.996Z","repository":{"id":57719602,"uuid":"142155334","full_name":"bohrqiu/dubbo-cache","owner":"bohrqiu","description":"@DubboCache提供dubbo消费者直接使用缓存的能力，当缓存不存在时，再访问远程dubbo服务。","archived":false,"fork":false,"pushed_at":"2018-07-30T09:20:13.000Z","size":92,"stargazers_count":8,"open_issues_count":1,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-19T12:18:53.433Z","etag":null,"topics":["cachefilter","dubbo","spring","spring-el"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bohrqiu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-24T12:28:00.000Z","updated_at":"2023-04-20T01:09:37.000Z","dependencies_parsed_at":"2022-09-02T12:31:44.352Z","dependency_job_id":null,"html_url":"https://github.com/bohrqiu/dubbo-cache","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bohrqiu/dubbo-cache","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bohrqiu%2Fdubbo-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bohrqiu%2Fdubbo-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bohrqiu%2Fdubbo-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bohrqiu%2Fdubbo-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bohrqiu","download_url":"https://codeload.github.com/bohrqiu/dubbo-cache/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bohrqiu%2Fdubbo-cache/sbom","scorecard":{"id":246987,"data":{"date":"2025-08-11","repo":{"name":"github.com/bohrqiu/dubbo-cache","commit":"43314b32653272b25cac01fd55b7ebcb8ffaed41"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Code-Review","score":0,"reason":"Found 0/29 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"25 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-5mc7-m686-p6jg","Warn: Project is vulnerable to: GHSA-gm48-83x4-84jg","Warn: Project is vulnerable to: GHSA-gw4j-4229-q4px","Warn: Project is vulnerable to: GHSA-qmfc-6www-fjqw","Warn: Project is vulnerable to: GHSA-v2rg-8cwr-75g8","Warn: Project is vulnerable to: GHSA-5mcr-gq6c-3hq2","Warn: Project is vulnerable to: GHSA-9vjp-v76f-g363","Warn: Project is vulnerable to: GHSA-cqqj-4p63-rrmm","Warn: Project is vulnerable to: GHSA-f256-j965-7f32","Warn: Project is vulnerable to: GHSA-grg4-wf29-r9vv","Warn: Project is vulnerable to: GHSA-p2v9-g2qv-p635","Warn: Project is vulnerable to: GHSA-p979-4mfw-53vg","Warn: Project is vulnerable to: GHSA-wm47-8v5p-wjpj","Warn: Project is vulnerable to: GHSA-wx5j-54mm-rqqq","Warn: Project is vulnerable to: GHSA-xfv3-rrfm-f2rv","Warn: Project is vulnerable to: GHSA-36p3-wjmg-h94x","Warn: Project is vulnerable to: GHSA-hh26-6xwr-ggv7","Warn: Project is vulnerable to: GHSA-4gc7-5j7h-4qph","Warn: Project is vulnerable to: GHSA-4wp7-92pw-q264","Warn: Project is vulnerable to: GHSA-g5mm-vmx4-3rg7","Warn: Project is vulnerable to: GHSA-ffvq-7w96-97p7","Warn: Project is vulnerable to: GHSA-558x-2xjg-6232","Warn: Project is vulnerable to: GHSA-564r-hj7v-mcr5","Warn: Project is vulnerable to: GHSA-9cmq-m9j5-mvww","Warn: Project is vulnerable to: GHSA-wxqc-pxw9-g2p8"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-17T07:46:59.899Z","repository_id":57719602,"created_at":"2025-08-17T07:46:59.899Z","updated_at":"2025-08-17T07:46:59.899Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28315879,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T14:58:17.114Z","status":"ssl_error","status_checked_at":"2026-01-11T14:55:53.580Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cachefilter","dubbo","spring","spring-el"],"created_at":"2026-01-11T17:32:25.457Z","updated_at":"2026-01-11T17:32:25.989Z","avatar_url":"https://github.com/bohrqiu.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# @DubboCache\n\n[![Build Status](https://travis-ci.org/bohrqiu/dubbo-cache.svg?branch=master)](https://travis-ci.org/bohrqiu/dubbo-cache)\n[![codecov](https://codecov.io/gh/bohrqiu/dubbo-cache/branch/master/graph/badge.svg)](https://codecov.io/gh/bohrqiu/dubbo-cache)\n[![maven](https://img.shields.io/maven-central/v/com.github.bohrqiu.dubbo/dubbo-cache.svg)](https://search.maven.org/#search%7Cga%7C1%7Cdubbo-cache)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n\n提供dubbo消费者直接使用缓存的能力，当缓存不存在时，再访问远程dubbo服务。\n\n相对于dubbo默认的缓存机制，此项目具有如下优点：\n\n1. 原生dubbo cache机制只能缓存结果到消费者jvm中，并且cache key不能选择。\n2. 缓存key生成灵活，和spring 声明式缓存一致，采用spring el表达式\n3. 可以扩展`CacheKeyValidator`接口，实现键缓存策略\n4. 可以扩展`CacheValueValidator`接口，实现值缓存策略\n5. 由于采用分布式缓存，服务提供端可以灵活控制缓存\n\n目前仅提供redis实现，依赖`spring-data-redis`.\n\n## 使用`@DubboCache`\n\n### 在服务接口模块中依赖`dubbo-cache-common`\n\t\n```xml\n\u003cdependency\u003e\n\t\u003cgroupId\u003ecom.github.bohrqiu.dubbo\u003c/groupId\u003e\n\t\u003cartifactId\u003edubbo-cache-common\u003c/artifactId\u003e\n\t\u003cversion\u003e1.2\u003c/version\u003e\n\u003c/dependency\u003e\n```\n此依赖仅定义了`@DubboCache`注解。\n      \n### 在服务实现模块中依赖`dubbo-cache-core`\n\n```xml\n\u003cdependency\u003e\n\t\u003cgroupId\u003ecom.github.bohrqiu.dubbo\u003c/groupId\u003e\n\t\u003cartifactId\u003edubbo-cache-core\u003c/artifactId\u003e\n\t\u003cversion\u003e1.2\u003c/version\u003e\n\u003c/dependency\u003e\n```  \n\n### 在服务接口上添加`@DubboCache`注解\n\n```java\npublic interface CacheableService {\n\t@DubboCache(cacheName = \"test\",key = \"#order.playload\")\n\tSingleValueResult\u003cString\u003e echo(SingleValueOrder\u003cString\u003e order);\n}\n```\n\n如上所示:`cacheName=test`,`key`为第一个参数的playload字段，缓存有效期默认5分钟。\n\t\n上面的注解和`@org.springframework.cache.annotation.Cacheable(value = \"test\", key = \"#order.playload\")`生成的key一致。\n\t\n对于dubbo服务消费者，只需要更新jar包即可，由服务提供者来觉得接口是否需要缓存，和缓存的控制。\n\n**注意:** 参数名读取依赖java8编译参数`-parameters`,上面的例子也可以通过`p0`来引用第一个接口入参。\n\n## key生成\n\nkey生成策略和`Cacheable`一致，上面的例子中cache key由两部分组成:cacheName,spring el表达式结果，用`:`分隔.\n\n如果请求参数order中`playload`属性值为dubbo，最终key为：`test:dubbo`\n\n如果服务有多个版本或者group，需要对多个版本和group分别设置缓存，可以设置参数：\n\n    cachePrefixContainGroup=true\n    cachePrefixContainVersion=true\n    \n如果两个参数都设置，key由四部分组成：cacheName,group,version,spring el表达式结果,用`:`分隔，建议在provider端设置此配置。\n\n## 控制缓存\n\n`@DubboCache`提供了消费者可优先使用缓存，**缓存的一致性由服务提供方负责**，当服务提供方使用此注解后，所有的服务消费者都会使用此缓存。\n\n控制缓存分为两种情况：\n\n1. 缓存一致性要求不高，可以通过`DubboCache#expire`设置过期时间，默认为5分钟。\n2. 缓存一致性要求高，服务提供方通过`redisTemplate`或者`org.springframework.cache.annotation.CacheEvict`控制缓存。\n\n## 如何扩展\n\n### 扩展`CacheKeyValidator`\n\n`CacheKeyValidator`可以实现对特定的key、url缓存或者不缓存。默认策略为：key不为null可以缓存。\n\n#### 实现`CacheKeyValidator`\n\t\t\n```java\t\npackage com.github.bohrqiu.dubbo.cache.validator;\npublic class TestCacheKeyValidator implements CacheKeyValidator {\n    @Override\n\tpublic boolean isValid(URL url, Invocation invocation, CacheMeta cacheMeta, Object elEvaluatedKey) {\n\t\tSystem.out.println(\"in TestCacheKeyValidator\");\n\t\treturn true;\n\t}\n}\n```\n\n#### 配置扩展文件\n\n在classpath下创建`META-INF/dubbo/com.github.bohrqiu.dubbo.cache.CacheKeyValidator`文件,内容为：\n\n\ttest=com.github.bohrqiu.dubbo.cache.validator.TestCacheValueValidator\n\t\n#### 设置服务url使自定义扩展生效\n\n可以通过在provider配置application时指定(更多配置方式，参考dubbo相关文档).\n\n```xml\n\u003cdubbo:application name=\"dubbo-cache-test\"\u003e\n\t\u003cdubbo:parameter key=\"cacheKeyValidator\" value=\"test\"/\u003e\n\u003c/dubbo:application\u003e\n```\n\n### 扩展`CacheKeyValidator`\n\n扩展方式和上面的类似，更多参考dubbo扩展机制。\t默认策略为：value不为null可以缓存。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbohrqiu%2Fdubbo-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbohrqiu%2Fdubbo-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbohrqiu%2Fdubbo-cache/lists"}