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

Method GetPreference

pkg/memory/preference.go:190–208  ·  view source on GitHub ↗

GetPreference 获取偏好

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

Source from the content-addressed store, hash-verified

188
189// GetPreference 获取偏好
190func (pm *PreferenceManager) GetPreference(
191 ctx context.Context,
192 userID string,
193 category PreferenceCategory,
194 key string,
195) (*Preference, error) {
196 pm.mu.RLock()
197 defer pm.mu.RUnlock()
198
199 pref := pm.findExistingPreference(userID, category, key)
200 if pref == nil {
201 return nil, errors.New("preference not found")
202 }
203
204 // 更新访问计数
205 pref.AccessCount++
206
207 return pref, nil
208}
209
210// ListPreferences 列出用户的所有偏好
211func (pm *PreferenceManager) ListPreferences(

Calls 1