MCPcopy
hub / github.com/usememos/memos / GetInstanceSetting

Method GetInstanceSetting

store/instance_setting.go:87–106  ·  view source on GitHub ↗
(ctx context.Context, find *FindInstanceSetting)

Source from the content-addressed store, hash-verified

85}
86
87func (s *Store) GetInstanceSetting(ctx context.Context, find *FindInstanceSetting) (*storepb.InstanceSetting, error) {
88 if cache, ok := s.instanceSettingCache.Get(ctx, find.Name); ok {
89 instanceSetting, ok := cache.(*storepb.InstanceSetting)
90 if ok {
91 return instanceSetting, nil
92 }
93 }
94
95 list, err := s.ListInstanceSettings(ctx, find)
96 if err != nil {
97 return nil, err
98 }
99 if len(list) == 0 {
100 return nil, nil
101 }
102 if len(list) > 1 {
103 return nil, errors.Errorf("found multiple instance settings with key %s", find.Name)
104 }
105 return list[0], nil
106}
107
108func (s *Store) GetInstanceBasicSetting(ctx context.Context) (*storepb.InstanceBasicSetting, error) {
109 instanceSetting, err := s.GetInstanceSetting(ctx, &FindInstanceSetting{

Calls 2

ListInstanceSettingsMethod · 0.95
GetMethod · 0.65

Tested by

no test coverage detected