{"id":38964529,"url":"https://github.com/jsrdxzw/redis-kit","last_synced_at":"2026-01-17T16:28:10.729Z","repository":{"id":53507737,"uuid":"266468373","full_name":"jsrdxzw/redis-kit","owner":"jsrdxzw","description":"this is a Redis Util Collections for distributed environment","archived":false,"fork":false,"pushed_at":"2022-04-29T09:52:55.000Z","size":128,"stargazers_count":38,"open_issues_count":0,"forks_count":7,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-30T05:53:04.966Z","etag":null,"topics":["distributed-lock","distributed-rate-limiter","high-performance","redis-kit"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jsrdxzw.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":"2020-05-24T04:20:12.000Z","updated_at":"2025-01-17T16:07:01.000Z","dependencies_parsed_at":"2022-09-20T17:50:54.794Z","dependency_job_id":null,"html_url":"https://github.com/jsrdxzw/redis-kit","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/jsrdxzw/redis-kit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsrdxzw%2Fredis-kit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsrdxzw%2Fredis-kit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsrdxzw%2Fredis-kit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsrdxzw%2Fredis-kit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jsrdxzw","download_url":"https://codeload.github.com/jsrdxzw/redis-kit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsrdxzw%2Fredis-kit/sbom","scorecard":{"id":539118,"data":{"date":"2025-08-11","repo":{"name":"github.com/jsrdxzw/redis-kit","commit":"2cd1942dd4a8d7b07b24db1a013b4a1676ae43a0"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"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":"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":"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":"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":"Code-Review","score":0,"reason":"Found 0/24 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":"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":"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: MIT License: 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":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 10 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"12 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-h46c-h94j-95f3","Warn: Project is vulnerable to: GHSA-jjjh-jjxp-wpff","Warn: Project is vulnerable to: GHSA-rgv9-q543-rqg4","Warn: Project is vulnerable to: GHSA-rc42-6c7j-7h5r","Warn: Project is vulnerable to: GHSA-xf96-w227-r7c4","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-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-20T07:46:08.160Z","repository_id":53507737,"created_at":"2025-08-20T07:46:08.160Z","updated_at":"2025-08-20T07:46:08.160Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28511864,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T13:38:16.342Z","status":"ssl_error","status_checked_at":"2026-01-17T13:37:44.060Z","response_time":85,"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":["distributed-lock","distributed-rate-limiter","high-performance","redis-kit"],"created_at":"2026-01-17T16:28:10.091Z","updated_at":"2026-01-17T16:28:10.721Z","avatar_url":"https://github.com/jsrdxzw.png","language":"Java","funding_links":[],"categories":["分布式开发"],"sub_categories":["微服务框架"],"readme":"## Redis Distributed Kit\n\nthis repo uses local sync lock and redis lock to provide high performance redis tools This redis kit is recommended in\nsingle redis machine.\n\n![distribute_lock](images/distribute-lock.jpg)\n\n### performance test report\nwe use our redis kit to compare with their performance in concurrent environment.\n\n1000qps * 10 count\n\n|  machine  | redisson  | redis-kit | redis-kit (preload mode)\n|  ----  | ----  | ---- | ---- |\n| single instance (lock)  | 5286ms | 5394ms | 5184ms  |\n| two instances (lock)  | 5854ms | 6620ms | 6184ms |\n| single instance (tryLock) | 1271ms | 738ms | 720ms  |\n| two instances (tryLock)  | 2230ms | 1714ms | 1620ms |\n\n*In conclusion, redis-kit is almost as fast as redisson when using lock, but\nwhen using tryLock the redis-kit is faster about 40% than redisson.*\n\n\n### Import Redis Kit in your project\n\n```xml\n\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.github.jsrdxzw\u003c/groupId\u003e\n    \u003cartifactId\u003eredis-kit-spring-boot-starter\u003c/artifactId\u003e\n    \u003cversion\u003e2.0.0\u003c/version\u003e\n\u003c/dependency\u003e\n\u003cdependency\u003e\n    \u003cgroupId\u003eorg.springframework.boot\u003c/groupId\u003e\n    \u003cartifactId\u003espring-boot-starter-data-redis\u003c/artifactId\u003e\n\u003c/dependency\u003e \n```\n\n```java\nimport com.jsrdxzw.redis.core.EnableRedisKit;\n\n@EnableRedisKit\npublic class SpringBootApplication {\n    public static void main(String[] args) {\n        SpringApplication.run(SpringBootApplication.class, args);\n    }\n}\n```\n\n### Use Distributed Lock\n\nby default `StringRedisTemplate` which is provided by Spring is used, Of course you can choose other RedisTemplate by\nyourself.\n\n```java\n\n@Configuration\npublic class DistributedLockConfiguration {\n    @Bean\n    public RedisLockFactory redisLockFactory(StringRedisTemplate redisTemplate) {\n        return new DefaultRedisLockFactory(redisTemplate);\n    }\n}\n```\n\nuse lock in your own business logic code\n\n```java\npublic class UserService {\n    @Autowired\n    private RedisLockFactory redisLockFactory;\n\n    public void method() {\n        RedisLock RLock = redisLockFactory.getLock(\"xzw\");\n        try {\n            //RLock.lock(); by default the expire time is 60s\n            // set expire time is recommended because busy waiting may cause deadlock\n            // when redis machine is down..\n            RLock.tryLock(30, TimeUnit.SECONDS);\n            //RLock.tryLock(30, TimeUnit.SECONDS, 3);\n            // your own logic\n        } finally {\n            RLock.unlock();\n        }\n    }\n}\n```\n\nIn the other way, annotations such as `@DistributedLock`, `DistributedTryLock` are also provided, please import the\nspring aop at the first place before using annotations.\n\n```xml\n\n\u003cdependency\u003e\n    \u003cgroupId\u003eorg.springframework.boot\u003c/groupId\u003e\n    \u003cartifactId\u003espring-boot-starter-aop\u003c/artifactId\u003e\n\u003c/dependency\u003e\n```\n\n```java\nimport org.springframework.boot.autoconfigure.SpringBootApplication;\nimport org.springframework.context.annotation.ComponentScan;\n\n@ComponentScan\n@SpringBootApplication(scanBasePackages = {\"your.path\", \"com.jsrdxzw.redis\"})\npublic class Application {\n    public static void main(String[] args) {\n        SpringApplication.run(Application.class, args);\n    }\n}\n```\n\n### example of distributed lock by annotation\n\n```java\n// @DistributedLock(lockKey = \"your key\")\n@DistributedTryLock(lockKey = \"your key\", waitTime = 10)\npublic void method(){\n        //...\n        }\n```\n\n### Notice\nwe don't recommend use redis lock with @Transactional because it may cause visibility problems.\n```java\n@Transactional\npublic void reduceStock(Long id) {\n    RedisLock lock = redisLockFactory.getLock(\"test2\");\n    try {\n        lock.lock();\n        SkuStock skuStock = skuStockRepository.getOne(id);\n        Integer stock = skuStock.getStock();\n        if (stock \u003e 0) {\n            log.info(\"stock is {}\", stock);\n            skuStock.setStock(stock - 1);\n            skuStockRepository.save(skuStock);\n        }\n        longAdder.increment();\n        log.info(\"这是第{}个请求, 改之前的stock:{}\", longAdder.longValue(), stock);\n    } finally {\n        // when lock is released by one client, the other client will\n        // get redis lock immediately when Transaction may not commit.\n        // The other client will get old value by using Mysql.\n        lock.unlock();\n    }\n\n}\n```\n\n### enable preload mode\n\nwe support preload mode from v1.0.4 that means the lua script is preloaded before used. it can save memory and increase\nperformance.\n\n```yaml\n# by default preload mode is disabled \nredis-kit:\n  preload: true\n```\n\n### Redis Cache Example\n\nit will get value from redis and if the key does not exist in redis it will do next process and put value in redis as\ncache. by default the expired time is `5 minutes`.\nredis key can retrieve params from invoked function.\n\n```java\n// key = id\n@Cache(key = \"id\", expireTime = 10, timeUnit = TimeUnit.SECONDS)\npublic somethingVo testCache(Integer id) {\n    //\n}\n\n// key = ro.title + ro.name\n@Cache(key = \"{title + name}\", expireTime = 10, timeUnit = TimeUnit.SECONDS)\npublic somethingVo testCache(MerchandiseGroupRo ro) {\n    //\n}\n\n// key = ro.title + id\n@Cache(key = \"{title}#id\", expireTime = 10, timeUnit = TimeUnit.SECONDS)\npublic somethingVo testCache(MerchandiseGroupRo ro, Integer id) {\n    //\n}\n\n// key = \"hello\"\n@Cache(key = \"hello\", expireTime = 10, timeUnit = TimeUnit.SECONDS)\npublic somethingVo testCache() {\n    //\n}\n```\n\nit will remove redis value based on cache principle\n-- [Cache aside](https://www.usenix.org/system/files/conference/nsdi13/nsdi13-final170_update.pdf)\n\nit is recommended to use @Transactional annotation when modifying cache values\n\n```java\n@Transactional(rollbackFor = Throwable.class)\n@Put(key = \"xzw\")\npublic Student methodName(){\n        }\n```\n\n`@Delete` is same as `@Put`\n\n```java\n@Transactional(rollbackFor = Throwable.class)\n@Delete(key = \"xzw\")\npublic void methodName(){\n        }\n```\n\nit will delete value from redis\n\n### rate limiter\n\n```java\nimport org.springframework.beans.factory.annotation.Autowired;\n\n@Autowired\nprivate RateLimit rateLimit;\n\nboolean require=rateLimit.acquire(\"xzw\",5,10);\n```\n\nit means we allow 5 requests per seconds, and when the request of per second is greater than 5, it will return false\n\nwe have provided three distributed limit rate algorithms:\n1. counter [by default]\n2. rolling window\n3. token bucket\n\n```yaml\n# you can change limit algorithm by overriding spring yaml file\nredis-kit:\n  rate-limit: \n    strategy: tokenBucket # default, rollingWindow\n    bucket-size: 100 # default is 10\n```\n\nalso, Spring AOP is used to support @Annotation features\n\n```java\nimport com.jsrdxzw.redis.ratelimit.RateLimiter;\n\n@RateLimiter(key = \"123\", limit = 10, time = 10, expire = 30)\npublic Object method() {\n    \n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsrdxzw%2Fredis-kit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjsrdxzw%2Fredis-kit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsrdxzw%2Fredis-kit/lists"}