title | description | template | last_updated | redirect_from | related | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
In Memory Persistence Strategy |
This document provides details about the In Memory Persistence Strategy service in the Components Library. |
concept-topic-template |
Nov 21, 2023 |
|
|
This document explains the In Memory Persistence Strategy service in the Components Library.
In Memory Persistence Strategy is an Angular Service that stores data in memory and will be lost when the browser page is reloaded.
Check out an example usage of the In Memory Persistence Strategy.
Service configuration:
storage
—persistence strategy type.
<spy-select
[datasource]="{
type: 'http',
...,
cache: {
...,
storage: 'in-memory',
},
}"
>
</spy-select>
Register the service:
declare module '@spryker/persistence' {
interface PersistenceStrategyRegistry {
'in-memory': InMemoryPersistenceStrategy;
}
}
@NgModule({
imports: [
PersistenceModule.withStrategies({
'in-memory': InMemoryPersistenceStrategy,
}),
],
})
export class RootModule {}
Below you can find interfaces for the In Memory Persistence Strategy:
interface InMemoryPersistenceStrategy extends PersistenceStrategy {
save(key: string, value: unknown): Observable<void>;
retrieve<T>(key: string): Observable<T | undefined>;
remove(key: string): Observable<void>;
}