OxiGDAL Cache Advanced
Advanced multi-tier caching system for OxiGDAL with ML-powered predictive prefetching, adaptive compression, and distributed cache support. Achieves high hit rates through intelligent access pattern learning and automatic data promotion/demotion across memory, SSD, and network tiers.
Features
- Multi-Tier Architecture: Automatic data promotion/demotion across L1 (memory), L2 (SSD), and L3 (network/disk)
- Predictive Prefetching: ML-based access pattern learning including Markov chains, neural networks, and Transformer models
- Adaptive Compression: Intelligent compression selection (LZ4, Zstd, Snappy) based on data types and patterns
- Advanced Eviction Policies: LRU, ARC, and W-TinyLFU eviction strategies per tier
- Cache Coherency: Multi-node cache coherency protocols with write-through and write-back policies
- Analytics & Observability: Detailed statistics, hit rate tracking, and distributed tracing support
- Async-First Design: Built with Tokio for high-performance non-blocking operations
- Pure Rust: 100% Pure Rust implementation with no C/Fortran dependencies
Installation
Add to your Cargo.toml:
[]
= "0.1"
= "1"
= { = "1", = ["full"] }
Quick Start
use ;
use Bytes;
async
Usage
Basic Cache Operations
use ;
use Bytes;
let cache = new.await?;
// Put data into cache
cache.put.await?;
// Get data from cache (promotes from lower tiers to higher ones)
let value = cache.get.await?;
// Check if key exists (doesn't update access statistics)
let exists = cache.contains.await;
// Remove from cache
cache.delete.await?;
// Get aggregated statistics across all tiers
let stats = cache.stats.await;
println!;
Predictive Prefetching
use ;
use Utc;
// Create predictor with Markov chain order 2
let mut predictor = new;
// Record access patterns
let records = vec!;
predictor.learn_from_records;
// Make predictions with confidence scores
let predictions = predictor.predict?;
for pred in predictions
Adaptive Compression
use ;
use Bytes;
let compressor = new;
// Compress data with adaptive algorithm selection
let data = from;
let compressed = compressor.compress?;
println!;
// Decompress transparently
let decompressed = compressor.decompress?;
assert_eq!;
Cache Warming
use CacheWarmer;
use Bytes;
let cache = new.await?;
let warmer = new;
// Pre-load frequently accessed data into cache
let keys_to_warm: = vec!;
warmer.warm_keys.await?;
println!;
Multi-Tier Statistics
let cache = new.await?;
// Per-tier statistics
let l1_stats = cache.tier_stats.await?;
let l2_stats = cache.tier_stats.await?;
let l3_stats = cache.tier_stats.await?;
println!;
println!;
println!;
Cache Coherency
use ;
let coherency = new?;
// Update data with coherency guarantee
coherency.update.await?;
// Invalidate across all nodes
coherency.invalidate.await?;
// Check coherency status
let status = coherency.status.await?;
println!;
Advanced Prediction Models
use ;
// Initialize neural network with embedding dimension 64
let nn_predictor = new?;
// Train on access patterns
let embeddings = vec!;
nn_predictor.update_embeddings?;
// Get predictions from neural network
let predictions = nn_predictor.predict?;
for pred in predictions
API Overview
| Module | Description |
|---|---|
multi_tier |
Multi-tier cache implementation with L1/L2/L3 tiers and automatic promotion |
predictive |
Access pattern learning and ML-based prediction models |
compression |
Adaptive compression with LZ4, Zstd, and Snappy algorithms |
eviction |
Eviction policies: LRU, ARC, W-TinyLFU |
coherency |
Cache coherency protocols for distributed environments |
write_policy |
Write-through and write-back policy implementations |
tiering |
Tier management and data migration logic |
warming |
Cache warming and preloading strategies |
partitioning |
Data partitioning for distributed cache |
analytics |
Cache analytics and performance tracking |
distributed |
Distributed cache protocol and communication |
observability |
Tracing and observability integration |
Core Types
CacheConfig: Configuration for cache sizes and featuresCacheValue: Cached data with metadata (timestamps, access count)CacheStats: Aggregated statistics (hits, misses, evictions)Prediction: ML prediction with confidence scoreMultiTierCache: Main cache interface
Performance
Benchmarks on Apple M1 (8-core, 16GB RAM):
| Operation | Throughput |
|---|---|
| L1 Get (hit) | ~2.5M ops/sec |
| L1 Put | ~1.8M ops/sec |
| L2 Get (SSD) | ~50K-100K ops/sec |
| Compression (LZ4) | ~500MB/sec |
| Decompression | ~1500MB/sec |
| Prediction (Markov) | ~10K predictions/sec |
| Neural Network Prediction | ~1K predictions/sec |
Hit rate improvements with prefetching:
- Baseline (no prefetch): 65-70%
- With Markov predictor: 78-82%
- With Neural Network: 84-88%
- With Transformer model: 88-92%
Examples
The repository includes comprehensive examples:
tests/multi_tier_test.rs- Multi-tier cache operationstests/predictive_test.rs- Predictive prefetching examplestests/advanced_prediction_test.rs- Advanced ML model usagetests/coherency_test.rs- Cache coherency patternstests/write_policy_test.rs- Write policy configurationsbenches/cache_bench.rs- Performance benchmarks
Configuration
Default Configuration
CacheConfig
Custom Configuration
let config = CacheConfig ;
let cache = new.await?;
Error Handling
This library follows the "no unwrap" policy. All fallible operations return Result<T, CacheError>:
use ;
async
Pure Rust
This library is 100% Pure Rust with no C/Fortran dependencies. All functionality works out of the box:
- Compression algorithms (LZ4, Zstd, Snappy) are pure Rust implementations
- ML models use Pure Rust numerical computation
- Async runtime via Tokio (Pure Rust)
- No external system dependencies
OxiGDAL Ecosystem
This project is part of the OxiGDAL ecosystem for geospatial data processing:
- OxiGDAL-Core: Core geospatial data structures
- OxiGDAL-Cache: Basic caching layer
- OxiGDAL-Cache-Advanced: Advanced caching with ML (this crate)
- OxiGDAL-Index: Spatial indexing for cached data
COOLJAPAN Policies
This project adheres to all COOLJAPAN development policies:
- ✅ Pure Rust: No C/Fortran dependencies
- ✅ No unwrap: All error handling via
Result<T, E> - ✅ Latest Dependencies: Uses latest available versions on crates.io
- ✅ Workspace: Uses workspace configuration for dependency management
- ✅ Refactoring: All modules kept under 2000 lines
Documentation
Full API documentation is available at docs.rs.
Key documentation sections:
Testing
Run the comprehensive test suite:
# All tests
# Specific test suite
# With logging
RUST_LOG=debug
# Benchmarks
Contributing
Contributions are welcome! Please ensure:
- All tests pass:
cargo test --all-features - No warnings:
cargo clippy -- -D warnings - Code is formatted:
cargo fmt - Documentation is complete:
cargo doc --no-deps
Related Projects
- OxiGDAL - Geospatial data processing
- OxiBLAS - Pure Rust BLAS
- OxiCode - Serialization framework
- SciRS2 - Scientific computing
License
Licensed under the Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0).
Acknowledgments
Developed as part of the COOLJAPAN ecosystem by Team Kitasan.
Part of the COOLJAPAN Pure Rust Ecosystem