Overview
The Storage Service provides an abstract interface for storing and retrieving data across different storage backends. It supports various storage locations (disk, memory, session) and optional secure storage encryption.StorageService
The base abstract class that all storage implementations must extend.Interface
Properties
valuesRequireDeserialization
Methods
get<T>()
key(string): The storage key to retrieveoptions(StorageOptions, optional): Configuration options for the storage operation
Promise<T> - The stored value, typed according to the generic parameter
Example:
has()
key(string): The storage key to checkoptions(StorageOptions, optional): Configuration options for the storage operation
Promise<boolean> - True if the key exists, false otherwise
Example:
save<T>()
key(string): The storage key to save underobj(T): The value to storeoptions(StorageOptions, optional): Configuration options for the storage operation
Promise<void>
Example:
remove()
key(string): The storage key to removeoptions(StorageOptions, optional): Configuration options for the storage operation
Promise<void>
Example:
ObservableStorageService
An interface that extends storage services with observable update streams.Interface
Properties
updates$
Observable<StorageUpdate> - Stream of storage update events
Example:
Types
StorageOptions
storageLocation(StorageLocation, optional): The location where data should be stored (disk, memory, or both)useSecureStorage(boolean, optional): Whether to use encrypted secure storageuserId(string, optional): User ID to scope the storage key to a specific userhtmlStorageLocation(HtmlStorageLocation, optional): HTML5 storage location (local, session, or memory)keySuffix(string, optional): Suffix to append to the storage key
StorageUpdate
key(string): The storage key that was updatedupdateType(StorageUpdateType): The type of update that occurred
StorageUpdateType
StorageLocation
Both: Store in both disk and memoryDisk: Store on disk for persistence across sessionsMemory: Store in memory only (cleared on restart)
HtmlStorageLocation
Local: Use localStorage (persists across sessions)Memory: Use in-memory storage (cleared on page reload)Session: Use sessionStorage (persists for session only)