MCPcopy Create free account
hub / github.com/dfinity/orbit / insert

Method insert

core/station/impl/src/repositories/user.rs:141–161  ·  view source on GitHub ↗
(&self, key: UserKey, value: User)

Source from the content-addressed store, hash-verified

139 }
140
141 fn insert(&self, key: UserKey, value: User) -> Option<User> {
142 DB.with(|m| {
143 CACHE.with(|cache| cache.borrow_mut().insert(key.id, value.clone()));
144
145 let prev = m.borrow_mut().insert(key, value.clone());
146
147 // Update metrics when a user is upserted.
148 USER_METRICS.with(|metrics| {
149 metrics
150 .iter()
151 .for_each(|metric| metric.borrow_mut().sum(&value, prev.as_ref()))
152 });
153
154 self.save_entry_indexes(&value, prev.as_ref());
155
156 let args = (value, prev);
157 self.change_observer.notify(&args);
158
159 args.1
160 })
161 }
162
163 fn remove(&self, key: &UserKey) -> Option<User> {
164 DB.with(|m| {

Callers 7

test_crudFunction · 0.45
add_entry_indexesMethod · 0.45
build_cacheMethod · 0.45
test_crudFunction · 0.45
test_find_by_identityFunction · 0.45

Calls 4

iterMethod · 0.80
sumMethod · 0.45
save_entry_indexesMethod · 0.45
notifyMethod · 0.45

Tested by 4

test_crudFunction · 0.36
test_crudFunction · 0.36
test_find_by_identityFunction · 0.36