MemoryAttachmentStorage
Class: MemoryAttachmentStorage
In-memory attachment storage implementation.
This is the default storage backend. It stores all attachments in a Map with O(1) access by ID. Suitable for development, testing, and small-scale deployments.
Limitations:
- Data is lost when the process restarts
- Memory usage scales linearly with stored data
- Not suitable for horizontal scaling (no shared state)
Implements
Constructors
new MemoryAttachmentStorage()
new MemoryAttachmentStorage(): MemoryAttachmentStorageReturns
Methods
clear()
clear(): Promise<number>Clear all stored attachments. Use with caution - this deletes all data.
Returns
Promise<number>
Number of attachments deleted
Implementation of
delete()
delete(id): Promise<boolean>Delete an attachment by ID.
Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | The attachment's snowflake ID |
Returns
Promise<boolean>
true if deleted, false if not found
Implementation of
deleteForMessage()
deleteForMessage(messageId): Promise<number>Delete all attachments for a specific message.
Parameters
| Parameter | Type | Description |
|---|---|---|
messageId | string | The message's snowflake ID |
Returns
Promise<number>
Number of attachments deleted
Implementation of
AttachmentStorage.deleteForMessage
deleteSync()
deleteSync(id): booleanParameters
| Parameter | Type |
|---|---|
id | string |
Returns
boolean
get()
get(id): Promise<undefined | StoredAttachment>Retrieve an attachment by ID.
Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | The attachment's snowflake ID |
Returns
Promise<undefined | StoredAttachment>
The stored attachment or undefined if not found
Implementation of
getAllSync()
getAllSync(): StoredAttachment[]Returns
getForMessage()
getForMessage(messageId): Promise<StoredAttachment[]>Get all attachments for a specific message.
Parameters
| Parameter | Type | Description |
|---|---|---|
messageId | string | The message's snowflake ID |
Returns
Promise<StoredAttachment[]>
Array of stored attachments belonging to the message
Implementation of
AttachmentStorage.getForMessage
getForMessageSync()
getForMessageSync(messageId): StoredAttachment[]Parameters
| Parameter | Type |
|---|---|
messageId | string |
Returns
getStats()
getStats(): Promise<StorageStats>Get storage statistics.
Returns
Promise<StorageStats>
Current storage metrics
Implementation of
getSync()
getSync(id): undefined | StoredAttachmentParameters
| Parameter | Type |
|---|---|
id | string |
Returns
undefined | StoredAttachment
store()
store(attachment): Promise<void>Store an attachment.
Parameters
| Parameter | Type | Description |
|---|---|---|
attachment | StoredAttachment | The attachment data to store |
Returns
Promise<void>
Promise that resolves when storage is complete
Implementation of
storeSync()
storeSync(attachment): voidParameters
| Parameter | Type |
|---|---|
attachment | StoredAttachment |
Returns
void
