pub struct SchemaCache {
keyspaces: Vec<KeyspaceMetadata>,
tables: HashMap<String, Vec<TableMetadata>>,
udts: HashMap<String, Vec<UdtMetadata>>,
functions: HashMap<String, Vec<FunctionMetadata>>,
aggregates: HashMap<String, Vec<AggregateMetadata>>,
last_refresh: Option<Instant>,
ttl: Duration,
}Expand description
Cached schema metadata for a CQL cluster.
Stores keyspaces, tables, UDTs, functions, and aggregates fetched from the
cluster. Lookup methods are synchronous — callers must call refresh() to
populate or update the cache.
Fields§
§keyspaces: Vec<KeyspaceMetadata>All keyspaces in the cluster.
tables: HashMap<String, Vec<TableMetadata>>Tables indexed by keyspace name.
udts: HashMap<String, Vec<UdtMetadata>>UDTs indexed by keyspace name.
functions: HashMap<String, Vec<FunctionMetadata>>Functions indexed by keyspace name.
aggregates: HashMap<String, Vec<AggregateMetadata>>Aggregates indexed by keyspace name.
last_refresh: Option<Instant>When the cache was last successfully refreshed.
ttl: DurationHow long before the cache is considered stale.
Implementations§
Source§impl SchemaCache
impl SchemaCache
Sourcepub fn is_stale(&self) -> bool
pub fn is_stale(&self) -> bool
Returns true if the cache has never been refreshed or its TTL has elapsed.
Sourcepub fn invalidate(&mut self)
pub fn invalidate(&mut self)
Force the cache to appear stale so the next access triggers a refresh.
Sourcepub async fn refresh(&mut self, session: &CqlSession) -> Result<()>
pub async fn refresh(&mut self, session: &CqlSession) -> Result<()>
Refresh the cache by fetching all schema metadata from the cluster.
Fetches all keyspaces first, then tables, UDTs, functions, and
aggregates for each keyspace in parallel (sequentially per keyspace for
simplicity — a future optimisation could use join_all).
Sourcepub fn keyspace_names(&self) -> Vec<&str>
pub fn keyspace_names(&self) -> Vec<&str>
Return the names of all cached keyspaces.
Sourcepub fn table_names(&self, keyspace: &str) -> Vec<&str>
pub fn table_names(&self, keyspace: &str) -> Vec<&str>
Return the names of all tables in keyspace.
Returns an empty Vec if the keyspace is unknown.
Sourcepub fn column_names(&self, keyspace: &str, table: &str) -> Vec<&str>
pub fn column_names(&self, keyspace: &str, table: &str) -> Vec<&str>
Return the names of all columns in keyspace.table.
Returns an empty Vec if the keyspace or table is unknown.
Sourcepub fn udt_names(&self, keyspace: &str) -> Vec<&str>
pub fn udt_names(&self, keyspace: &str) -> Vec<&str>
Return the names of all UDTs in keyspace.
Returns an empty Vec if the keyspace is unknown.
Sourcepub fn function_names(&self, keyspace: &str) -> Vec<&str>
pub fn function_names(&self, keyspace: &str) -> Vec<&str>
Return the names of all functions in keyspace.
Returns an empty Vec if the keyspace is unknown.
Sourcepub fn aggregate_names(&self, keyspace: &str) -> Vec<&str>
pub fn aggregate_names(&self, keyspace: &str) -> Vec<&str>
Return the names of all aggregates in keyspace.
Returns an empty Vec if the keyspace is unknown.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SchemaCache
impl RefUnwindSafe for SchemaCache
impl Send for SchemaCache
impl Sync for SchemaCache
impl Unpin for SchemaCache
impl UnwindSafe for SchemaCache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more