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

Method insert

core/station/impl/src/repositories/user_group.rs:105–122  ·  view source on GitHub ↗
(&self, key: UserGroupId, value: UserGroup)

Source from the content-addressed store, hash-verified

103 }
104
105 fn insert(&self, key: UserGroupId, value: UserGroup) -> Option<UserGroup> {
106 DB.with(|m| {
107 CACHE.with(|cache| cache.borrow_mut().insert(key, value.clone()));
108
109 let prev = m.borrow_mut().insert(key, value.clone());
110
111 // Update metrics when a user group is upserted.
112 USER_GROUP_METRICS.with(|metrics| {
113 metrics
114 .iter()
115 .for_each(|metric| metric.borrow_mut().sum(&value, prev.as_ref()))
116 });
117
118 self.save_entry_indexes(&value, prev.as_ref());
119
120 prev
121 })
122 }
123
124 fn remove(&self, key: &UserGroupId) -> Option<UserGroup> {
125 DB.with(|m| {

Callers 4

add_entry_indexesMethod · 0.45
build_cacheMethod · 0.45
test_crudFunction · 0.45
test_find_by_nameFunction · 0.45

Calls 3

iterMethod · 0.80
sumMethod · 0.45
save_entry_indexesMethod · 0.45

Tested by 2

test_crudFunction · 0.36
test_find_by_nameFunction · 0.36