{"id":18693759,"url":"https://github.com/hankquan/spring-enhanced-cache","last_synced_at":"2025-08-08T12:08:20.121Z","repository":{"id":43294926,"uuid":"466685908","full_name":"hankquan/spring-enhanced-cache","owner":"hankquan","description":"Project to enhance spring cache","archived":false,"fork":false,"pushed_at":"2025-02-26T12:21:37.000Z","size":54,"stargazers_count":14,"open_issues_count":0,"forks_count":6,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-13T19:42:42.309Z","etag":null,"topics":["spring","spring-boot-starter","spring-cache"],"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/hankquan.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-03-06T09:02:45.000Z","updated_at":"2025-04-22T01:51:26.000Z","dependencies_parsed_at":"2025-04-12T06:52:50.606Z","dependency_job_id":"039317c6-88d4-489c-b99a-c3eb0d9d341b","html_url":"https://github.com/hankquan/spring-enhanced-cache","commit_stats":null,"previous_names":["hankquan/spring-enhanced-cache","howaric/spring-enhanced-cache"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/hankquan/spring-enhanced-cache","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hankquan%2Fspring-enhanced-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hankquan%2Fspring-enhanced-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hankquan%2Fspring-enhanced-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hankquan%2Fspring-enhanced-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hankquan","download_url":"https://codeload.github.com/hankquan/spring-enhanced-cache/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hankquan%2Fspring-enhanced-cache/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269417542,"owners_count":24413384,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-08T02:00:09.200Z","response_time":72,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["spring","spring-boot-starter","spring-cache"],"created_at":"2024-11-07T11:06:58.757Z","updated_at":"2025-08-08T12:08:20.075Z","avatar_url":"https://github.com/hankquan.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# spring-enhanced-cache project\n\n[![CI](https://github.com/howaric/spring-enhanced-cache/actions/workflows/maven-publish.yml/badge.svg?branch=main)](https://github.com/howaric/spring-enhanced-cache/actions/workflows/maven-publish.yml)\n[![License](https://img.shields.io/github/license/howaric/spring-enhanced-cache.svg)](http://www.apache.org/licenses/LICENSE-2.0)\n![Maven Central](https://img.shields.io/maven-central/v/cn.howaric.cache/spring-enhanced-cache)\n\n## Overview\n\nThis project aims to enhance springboot cache without code invasion in high concurrency scenarios.\n\n## Features\n\n- [X]  Support to evict cache again in a delay time by @CacheEvict\n- [ ]  Provide retry mechanism when eviction of cache failed\n- [ ]  Random cache TTL in a specific range\n\n## Usage\n\n### Add dependency\n\nLatest version: [![Github release](https://img.shields.io/github/v/release/howaric/spring-enhanced-cache.svg)](https://GitHub.com/howaric/spring-enhanced-cache/releases)\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecn.howaric.cache\u003c/groupId\u003e\n    \u003cartifactId\u003espring-boot-starter-cache-enhancer\u003c/artifactId\u003e\n    \u003cversion\u003e${latest.version}\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n\u003e spring-boot-starter-cache won't be needed when this dependency is added in your project.\n\nAdd a cache implementation, here uses redis as an example.\n\n```xml\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\nYou can define your own CacheManager, or use the default CacheManager which created by spring cache AutoConfiguration.\n\n### Setup configuration\n\nWith spring-enhanced-cache, there will be an EnhancedCacheManager created and injected as a spring bean automaticly. The default name of the EnhancedCacheManager is `cn.howaric.cache.enhancer.EnhancedCacheManager.ENHANCED_CACHE_MANAGER`, it can also be specified by `spring.cache.enhanced.enhancedCacheManagerName` in spring application.yml.\n\n```yaml\nspring:\n  cache:\n    type: redis\n    redis:\n      time-to-live: 10000 # time unit is millis\n    enhancer:\n      # enhanced-cache-manager-name: \"customEnhancedCacheManager\" # name of the cache manager\n      delay-time: 2000 # means deleting cache eviction again after 2s, default is 5s\n```\n\nBy specifying this enhanced CacheManager in @CacheEvict annotation, it will trigger a delayed eviction of the cache in the specific delay time.\n\n```java\n@CacheEvict(key = \"#p0.username\", cacheManager = EnhancedCacheManager.ENHANCED_CACHE_MANAGER)\npublic void updateUser(User user) {\n  //update user\n}\n```\n\n## Troubleshooting\n\n1. How to make sure the EnhancedCacheManager really trigger the delayed eviction of cache?\n\nYou can just open the debug log for package `cn.howaric.cache.enhancer`, then you will see the related logs.\n\n```yaml\nlogging:\n  level:\n    cn.howaric.cache.enhancer: debug\n```\n\nLogs example,\n\n```tex\n2022-03-07 21:56:40.780 DEBUG 85337 --- [nio-8080-exec-1] c.h.c.e.listener.ListenableCache       : Evict cache\n2022-03-07 21:56:40.782 DEBUG 85337 --- [nio-8080-exec-1] c.h.c.e.listener.ListenableCache       : Evict cache delayed operation published\n2022-03-07 21:56:42.804 DEBUG 85337 --- [pool-1-thread-1] c.h.c.e.listener.EvictCacheOperation   : Re-evict cache\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhankquan%2Fspring-enhanced-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhankquan%2Fspring-enhanced-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhankquan%2Fspring-enhanced-cache/lists"}