MCPcopy Create free account
hub / github.com/elastic/devfiler / insert

Method insert

src/storage/table.rs:136–150  ·  view source on GitHub ↗

Inserts the given value at the given key. If the record already exists, the previous value is replaced.

(&self, key: Self::Key, value: Self::Value)

Source from the content-addressed store, hash-verified

134 ///
135 /// If the record already exists, the previous value is replaced.
136 fn insert(&self, key: Self::Key, value: Self::Value) {
137 let key_raw = key.into_raw();
138 let value_bytes = rkyv::to_bytes(&value).unwrap();
139
140 // Update cache
141 if Self::CACHE_SIZE > 0 {
142 let mut cache = self.cache().lock().unwrap();
143 cache.put(key_raw.as_ref().to_vec(), value_bytes.to_vec());
144 }
145
146 match Self::MERGE_OP {
147 MergeOperator::Default => self.raw().put(key_raw, value_bytes).unwrap(),
148 MergeOperator::Associative(_) => self.raw().merge(key_raw, value_bytes).unwrap(),
149 }
150 }
151
152 /// Create a new insertion batch.
153 fn batched_insert(&self) -> InsertionBatch<'_, Self> {

Callers

nothing calls this directly

Calls 1

into_rawMethod · 0.45

Tested by

no test coverage detected