Package dev.cachly
Class EdgeCacheClient
java.lang.Object
dev.cachly.EdgeCacheClient
Client for managing Cloudflare Edge Cache for a cachly instance.
Provides methods to get/set configuration, purge cache, and retrieve statistics.
Obtain via CachlyClient.edge().
Example usage
EdgeCacheClient edge = client.edge();
// Enable edge caching with 120s TTL
EdgeCacheConfig cfg = edge.setConfig(
EdgeCacheConfigUpdate.builder()
.enabled(true)
.edgeTtl(120)
.build()
);
// Purge specific namespaces
EdgePurgeResult result = edge.purge(
EdgePurgeOptions.forNamespaces(List.of("cachly:sem:qa"))
);
// Check stats
EdgeCacheStats stats = edge.stats();
System.out.printf("Hit rate: %.1f%%\n", stats.getHitRate() * 100);
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidDelete the edge cache configuration (disables edge caching).Delete configuration asynchronously.Get the current edge cache configuration.Get configuration asynchronously.purge()Purge all cached entries.purge(EdgePurgeOptions options) Purge cached entries from the Cloudflare CDN.purgeAsync(EdgePurgeOptions options) Purge asynchronously.setConfig(EdgeCacheConfigUpdate update) Update the edge cache configuration.setConfigAsync(EdgeCacheConfigUpdate update) Set configuration asynchronously.stats()Get edge cache hit/miss statistics.Get stats asynchronously.
-
Constructor Details
-
EdgeCacheClient
Create a new EdgeCacheClient.- Parameters:
edgeApiUrl- Edge Cache Management API URL (e.g., https://api.cachly.dev/v1/edge/{token})
-
-
Method Details
-
getConfig
Get the current edge cache configuration.- Returns:
- current configuration
-
getConfigAsync
Get configuration asynchronously. -
setConfig
Update the edge cache configuration.- Parameters:
update- configuration update- Returns:
- updated configuration
-
setConfigAsync
Set configuration asynchronously. -
deleteConfig
public void deleteConfig()Delete the edge cache configuration (disables edge caching). -
deleteConfigAsync
Delete configuration asynchronously. -
purge
Purge cached entries from the Cloudflare CDN.- Parameters:
options- purge options (namespaces or URLs); pass null to purge all- Returns:
- purge result with count and affected URLs
-
purge
Purge all cached entries. -
purgeAsync
Purge asynchronously. -
stats
Get edge cache hit/miss statistics.- Returns:
- cache statistics
-
statsAsync
Get stats asynchronously.
-