MCPcopy Create free account
hub / github.com/erans/pgsqlite / get_enum_values

Method get_enum_values

src/cache/enum_cache.rs:107–130  ·  view source on GitHub ↗

Get ENUM values for a type (with caching)

(&self, conn: &Connection, type_oid: i32)

Source from the content-addressed store, hash-verified

105
106 /// Get ENUM values for a type (with caching)
107 pub fn get_enum_values(&self, conn: &Connection, type_oid: i32) -> rusqlite::Result<Vec<EnumValue>> {
108 // Check cache first
109 {
110 let cache = self.values_by_type.read().unwrap();
111 if let Some(entry) = cache.get(&type_oid)
112 && entry.timestamp.elapsed() < self.ttl {
113 return Ok(entry.data.clone());
114 }
115 }
116
117 // Load from database
118 let values = EnumMetadata::get_enum_values(conn, type_oid)?;
119
120 // Cache result
121 {
122 let mut cache = self.values_by_type.write().unwrap();
123 cache.insert(type_oid, CacheEntry {
124 data: values.clone(),
125 timestamp: Instant::now(),
126 });
127 }
128
129 Ok(values)
130 }
131
132 /// Validate if a value is valid for an ENUM type (uses cache)
133 pub fn is_valid_enum_value(&self, conn: &Connection, type_oid: i32, label: &str) -> rusqlite::Result<bool> {

Callers 1

is_valid_enum_valueMethod · 0.45

Calls 4

readMethod · 0.80
getMethod · 0.45
cloneMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected