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

Method Get

pkg/memory/logic/store_inmemory.go:65–82  ·  view source on GitHub ↗

Get 获取单个 Memory

(ctx context.Context, namespace, key string)

Source from the content-addressed store, hash-verified

63
64// Get 获取单个 Memory
65func (s *InMemoryStore) Get(ctx context.Context, namespace, key string) (*LogicMemory, error) {
66 s.mu.RLock()
67 defer s.mu.RUnlock()
68
69 if s.closed {
70 return nil, ErrStoreClosed
71 }
72
73 storeKey := makeKey(namespace, key)
74 memory, exists := s.memories[storeKey]
75 if !exists {
76 return nil, ErrMemoryNotFound
77 }
78
79 // 返回拷贝
80 result := *memory
81 return &result, nil
82}
83
84// Delete 删除 Memory
85func (s *InMemoryStore) Delete(ctx context.Context, namespace, key string) error {

Callers 8

TestInMemoryStore_PruneFunction · 0.95
TestInMemoryStore_CloseFunction · 0.95
TestRecordMemoryFunction · 0.95
TestProcessEventFunction · 0.95
TestRetrieveMemoriesFunction · 0.95
TestPruneMemoriesFunction · 0.95

Calls 1

makeKeyFunction · 0.70

Tested by 8

TestInMemoryStore_PruneFunction · 0.76
TestInMemoryStore_CloseFunction · 0.76
TestRecordMemoryFunction · 0.76
TestProcessEventFunction · 0.76
TestRetrieveMemoriesFunction · 0.76
TestPruneMemoriesFunction · 0.76