pub struct QueryCache { /* private fields */ }Expand description
Cache for compiled queries
Queries are compiled lazily on first access from the source provided by language plugins.
Uses interior mutability (RwLock) to allow lazy compilation through &self references.
Uses Arc
Implementations§
Source§impl QueryCache
impl QueryCache
Sourcepub fn get(
&self,
language_id: &str,
query_type: QueryType,
) -> Option<Arc<Query>>
pub fn get( &self, language_id: &str, query_type: QueryType, ) -> Option<Arc<Query>>
Get a cached query (does not compile if not cached)
Returns an Arc clone for cheap sharing with syntax providers.
Sourcepub fn compile_and_cache(
&self,
language_id: &str,
query_type: QueryType,
ts_language: &Language,
source: &str,
) -> Option<Arc<Query>>
pub fn compile_and_cache( &self, language_id: &str, query_type: QueryType, ts_language: &Language, source: &str, ) -> Option<Arc<Query>>
Compile and cache a query from source
Returns an Arc clone of the compiled query, or None if compilation fails. Uses interior mutability via RwLock.
Sourcepub fn get_or_compile(
&self,
language_id: &str,
query_type: QueryType,
ts_language: &Language,
source: &str,
) -> Option<Arc<Query>>
pub fn get_or_compile( &self, language_id: &str, query_type: QueryType, ts_language: &Language, source: &str, ) -> Option<Arc<Query>>
Get a cached query, or compile and cache it on first access (lazy compilation)
This is the primary method for lazy query access. Checks the cache first with a read lock, then compiles with a write lock if not cached.
Sourcepub fn is_cached(&self, language_id: &str, query_type: QueryType) -> bool
pub fn is_cached(&self, language_id: &str, query_type: QueryType) -> bool
Check if a query is cached
Sourcepub fn clear_language(&self, language_id: &str)
pub fn clear_language(&self, language_id: &str)
Clear cached queries for a specific language