How babyblue94520/polar-bear-cache works
Project type and purpose
• This is a Spring-Boot‐compatible caching library (a Spring Boot “starter”) that provides local in-memory caching across multiple services.
• It leverages Spring’s @Cacheable and @CacheEvict semantics, wraps them with AOP, and broadcasts eviction events over a message queue (e.g. Redis pub/sub).
File structure
• Top‐level: pom.xml, mvnw scripts, src/main/java/pers/clare/polarbearcache (the library code), src/test/java/pers/clare/polarbearcache (unit tests), plus an example test application under src/test/java/pers/clare/polarbeartest.
• Key packages:
• annotation (CacheAlive)
• aop (CachePutAop)
• event (EventSender, EventReceiver)
• impl (BasicCacheManager, BasicCache, ValueWrapper)
• processor (annotation parsing)
• support (CacheDependency, key utilities, volatile senders)
• Resources: META-INF/spring.factories for auto-configuration.
README
• Core design: use MQ to broadcast cache‐evict events so each service clears its local in‐memory caches, reducing external I/O and CPU overhead.
• Usage: annotated @EnablePolarBearCache, define a PolarBearCacheManager bean (e.g. BasicCacheManager), optionally supply a PolarBearCacheEventService implementation (e.g. Redis).