Skip to main content

Module cache

Module cache 

Source
Expand description

Query cache for parsed and planned queries.

This module provides an LRU cache for query plans to avoid repeated parsing and optimization of frequently executed queries.

§Cache Levels

  • Parsed cache: Caches logical plans after translation (language-specific parsing)
  • Optimized cache: Caches logical plans after optimization

§Usage

use grafeo_engine::query::cache::{QueryCache, CacheKey};
use grafeo_engine::query::processor::QueryLanguage;
use grafeo_engine::query::plan::{LogicalPlan, LogicalOperator};

let cache = QueryCache::new(1000);
let cache_key = CacheKey::new("MATCH (n) RETURN n", QueryLanguage::Gql);

// Check cache first
if let Some(plan) = cache.get_optimized(&cache_key) {
    // use cached plan
}

// Parse and optimize, then cache
let plan = LogicalPlan::new(LogicalOperator::Empty);
cache.put_optimized(cache_key, plan);

Structs§

CacheKey
Cache key combining query text, language, and active graph.
CacheStats
Cache statistics.
CachingQueryProcessor
A caching wrapper for the query processor.
QueryCache
Query cache for parsed and optimized plans.