Cache Layer
High-performance caching for qqq applications with Redis and in-memory support.
CachingGitHub
Overview
The Cache Layer qBit provides a unified caching interface for qqq applications. It abstracts away the complexity of different caching backends while providing a consistent API.
Features
When to Use
Use the Cache Layer qBit when you need to:
Installation
Maven
Add the following dependency to your pom.xml:
XML
<dependency>
<groupId>io.qrun</groupId>
<artifactId>qbit-cache-layer</artifactId>
<version>2.1.0</version>
</dependency>Gradle
Groovy
implementation 'io.qrun:qbit-cache-layer:2.1.0'Requirements
Configuration
Redis Backend
YAML
cache:
backend: redis
redis:
host: localhost
port: 6379
password: ${REDIS_PASSWORD}
database: 0
ssl: trueIn-Memory Backend
YAML
cache:
backend: memory
memory:
maxSize: 10000
expireAfterWrite: 3600Configuration Options
| Option | Default | Description |
|---|---|---|
backend | memory | Cache backend (redis, memory) |
defaultTtl | 3600 | Default TTL in seconds |
keyPrefix | qqq: | Prefix for cache keys |
API Reference
CacheService
The main interface for cache operations.
Java
@Inject
private CacheService cacheService;
// Get from cache
Optional<Customer> customer = cacheService.get("customer:123", Customer.class);
// Put in cache
cacheService.put("customer:123", customer, Duration.ofMinutes(5));
// Delete from cache
cacheService.delete("customer:123");Annotations
Java
@Cacheable(key = "customer:#{id}", ttl = 300)
public Customer getCustomer(Integer id) {
// Method implementation
}Knowledge Base
Powered by qqq