# Interface IMemoryBackend

Interface for memory backend implementations.

interface IMemoryBackend {
store(
key: string,
value: unknown,
metadata: MemoryMetadata,
): Promise<Result<void, MemoryError>>;
retrieve(key: string): Promise<Result<unknown, MemoryError>>;
search(
query: string,
limit: number,
): Promise<Result<MemoryEntry[], MemoryError>>;
prune(olderThan: Date): Promise<Result<number, MemoryError>>;
}

- Defined in packages/nexus-agents/src/context/memory-backend-types.ts:104

##### Index

### Methods

store
retrieve
search
prune

## Methods

### store

- store(
  key: string,
  value: unknown,
  metadata: MemoryMetadata,
  ): Promise<Result<void, MemoryError>>

  Store a value with associated metadata.

  #### Parameters

  - key: string

    Unique key for the memory

  - value: unknown

    The value to store (must be JSON-serializable)

  - metadata: MemoryMetadata

    Associated metadata

  #### Returns Promise<Result<void, MemoryError>>

  - Defined in packages/nexus-agents/src/context/memory-backend-types.ts:111

### retrieve

- retrieve(key: string): Promise<Result<unknown, MemoryError>>

  Retrieve a value by key.

  #### Parameters

  - key: string

    The key to look up

  #### Returns Promise<Result<unknown, MemoryError>>

  The value or null if not found

  - Defined in packages/nexus-agents/src/context/memory-backend-types.ts:118

### search

- search(
  query: string,
  limit: number,
  ): Promise<Result<MemoryEntry[], MemoryError>>

  Search memories using full-text search.

  #### Parameters

  - query: string

    Search query string

  - limit: number

    Maximum number of results

  #### Returns Promise<Result<MemoryEntry[], MemoryError>>

  - Defined in packages/nexus-agents/src/context/memory-backend-types.ts:125

### prune

- prune(olderThan: Date): Promise<Result<number, MemoryError>>

  Remove memories older than the specified date.

  #### Parameters

  - olderThan: Date

    Cutoff date for pruning

  #### Returns Promise<Result<number, MemoryError>>

  Number of entries pruned

  - Defined in packages/nexus-agents/src/context/memory-backend-types.ts:132