agentsclimarketplace

Cocache

Skill Ahoo-Wang/skills/sources/CoCache/skills/cocache

A central aggregation repository for Agent Skills from Ahoo-Wang's open source projects.

Install
npx -y skills add Ahoo-Wang/skills --skill cocache

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 3 stars3 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Use when building or modifying Java/Kotlin applications with CoCache two-level distributed coherent caching. Invoke for @CoCache cache interfaces, @JoinCacheable composition, Redis-backed coherence, Spring Boot integration, cache proxy behavior, custom cache backends, cache breakdown protection, or CoCache TCK tests.

SKILL.md

4.8 KB, as published. Nobody here has run it

CoCache Development Guide

CoCache is a Java/Kotlin two-level distributed coherent cache framework:

  • L2 client-side cache: local Map, Guava, or Caffeine cache.
  • L1 distributed cache: Redis-backed shared cache.
  • Coherence: CacheEvictedEventBus publishes evictions so peer instances invalidate local entries.

Start Here

Choose the smallest reference that fits the request:

TaskRead
Add CoCache to a Spring or Spring Boot appreferences/setup.md
Compose cached values with @JoinCacheablereferences/join-cache.md
Write or update testsreferences/testing.md
Implement a custom L1/L2 cache, event bus, key converter, or sourcereferences/custom-implementation.md

Repository Rules

When editing this repository, follow AGENTS.md:

  • Use me.ahoo.test.asserts.assert and .assert() in Kotlin tests; do not use AssertJ assertThat().
  • Extend the TCK specs in cocache-test for cache implementations.
  • Ask before changing cocache-api public interfaces or adding dependencies.
  • Run the relevant Gradle checks before finishing; prefer ./gradlew check for broad changes.

Core Model

Define one cache interface per cache domain. The interface extends Cache<K, V>, is annotated with @CoCache, and is registered through @EnableCoCache. CoCache creates a proxy at runtime.

@CoCache(keyPrefix = "user:", ttl = 120)
@GuavaCache(maximumSize = 1_000_000, expireAfterAccess = 120, expireUnit = TimeUnit.SECONDS)
interface UserCache : Cache<String, User>

@SpringBootApplication
@EnableCoCache(caches = [UserCache::class])
class App

Use caches through Kotlin operators: cache[key], cache[key] = value, cache.evict(key), and cache.getCache(key) when CacheValue metadata is required.

Extension Points

CoCache auto-configures defaults, but each component can be overridden:

  • Per cache, define named beans such as UserCache.CacheSource, UserCache.ClientSideCache, UserCache.KeyConverter, or UserCache.JoinKeyExtractor.
  • Globally, define beans by type; auto-configured beans use @ConditionalOnMissingBean.
  • For data loading, implement CacheSource<K, V>.loadCacheValue(key) and return DefaultCacheValue.forever(value), DefaultCacheValue.ttlAt(value, ttl), or bounded DefaultCacheValue.missingGuard(ttl, amplitude) values.

Testing Pattern

CoCache provides abstract specs in cocache-test for compatibility coverage:

  • CacheSpec<K,V> for base cache behavior.
  • ClientSideCacheSpec<V> for L2 caches.
  • DistributedCacheSpec<V> for L1 caches.
  • DefaultCoherentCacheSpec<K,V> for two-level coherent cache behavior and cache breakdown protection.
  • MultipleInstanceSyncSpec<K,V> and CacheEvictedEventBusSpec for cross-instance coherence and event buses.

Use the repo's createCacheEntry(): Pair<K, V> contract:

class MyDistributedCacheTest : DistributedCacheSpec<String>() {
    override fun createCache(): DistributedCache<String> {
        return MyDistributedCache()
    }

    override fun createCacheEntry(): Pair<String, String> {
        return UUID.randomUUID().toString() to "test_value"
    }
}

Key Classes

ClassModulePurpose
Cache<K,V>cocache-apiBase cache interface
CoherentCache<K,V>cocache-coreTwo-level cache engine
DefaultCoherentCachecocache-coreDefault implementation
ClientSideCache<V>cocache-apiL2 local cache interface
MapClientSideCachecocache-coreConcurrentHashMap impl
GuavaClientSideCachecocache-coreGuava Cache impl
CaffeineClientSideCachecocache-coreCaffeine Cache impl
DistributedCache<V>cocache-coreL1 distributed cache interface
RedisDistributedCachecocache-spring-redisRedis impl
CacheSource<K,V>cocache-apiData source loader
CacheEvictedEventBuscocache-coreEvent bus for coherence
RedisCacheEvictedEventBuscocache-spring-redisRedis Pub/Sub impl
JoinCache<K1,V1,K2,V2>cocache-apiComposed cache interface
SimpleJoinCachecocache-coreDefault JoinCache impl
KeyFiltercocache-coreBloom filter for cache breakdown protection
BloomKeyFiltercocache-coreGuava BloomFilter impl

Build Commands

./gradlew build -x test
./gradlew test
./gradlew :cocache-core:test
./gradlew :cocache-core:test --tests "me.ahoo.cache.proxy.ProxyCacheTest"
./gradlew :cocache-spring-redis:check
./gradlew :cocache-spring-boot-starter:check
./gradlew check

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.