MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / storageForUser

Method storageForUser

modules/storage/admin.go:128–140  ·  view source on GitHub ↗

storageForUser returns the username and storage items for a given userId, preferring the in-memory copy for online users and falling back to disk for offline ones.

(userId int)

Source from the content-addressed store, hash-verified

126// storageForUser returns the username and storage items for a given userId,
127// preferring the in-memory copy for online users and falling back to disk for offline ones.
128func (m *StorageModule) storageForUser(userId int) (username string, storageItems []items.Item) {
129 if u := users.GetByUserId(userId); u != nil {
130 data := m.storage[userId]
131 return u.Username, data.getItems()
132 }
133 // Offline: find username from index then load from disk.
134 idx := users.GetUserIndex()
135 if name, ok := idx.FindByUserId(userId); ok {
136 username = name
137 }
138 offlineData := m.load(userId)
139 return username, offlineData.getItems()
140}

Callers 1

apiAdminGetStorageMethod · 0.95

Calls 5

loadMethod · 0.95
GetByUserIdFunction · 0.92
GetUserIndexFunction · 0.92
getItemsMethod · 0.80
FindByUserIdMethod · 0.80

Tested by

no test coverage detected