MCPcopy Create free account
hub / github.com/astercloud/aster / ListPreferences

Method ListPreferences

pkg/memory/preference.go:211–227  ·  view source on GitHub ↗

ListPreferences 列出用户的所有偏好

(
	ctx context.Context,
	userID string,
	category PreferenceCategory,
)

Source from the content-addressed store, hash-verified

209
210// ListPreferences 列出用户的所有偏好
211func (pm *PreferenceManager) ListPreferences(
212 ctx context.Context,
213 userID string,
214 category PreferenceCategory,
215) ([]*Preference, error) {
216 pm.mu.RLock()
217 defer pm.mu.RUnlock()
218
219 if category == "" {
220 // 返回所有偏好
221 return pm.preferences[userID], nil
222 }
223
224 // 返回特定类别的偏好
225 indexKey := fmt.Sprintf("%s:%s", userID, category)
226 return pm.categoryIndex[indexKey], nil
227}
228
229// UpdatePreference 更新偏好
230func (pm *PreferenceManager) UpdatePreference(

Callers 1

Calls

no outgoing calls

Tested by 1