Get 获取单个 Memory
(ctx context.Context, namespace, key string)
| 63 | |
| 64 | // Get 获取单个 Memory |
| 65 | func (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 |
| 85 | func (s *InMemoryStore) Delete(ctx context.Context, namespace, key string) error { |