0.0.8 • Published 6 years ago

@tekbox/unified-storage v0.0.8

Weekly downloads
-
License
-
Repository
-
Last release
6 years ago

@tekbox/unified-storage

Unified-Storage is a simple key value storage interface for different backends. For currently available storage backends check src/adapters. To write your own storage adapter just extend AbstractStorageAdapter.

Usage

Available methods:

export interface IUnifiedStorage {
    set(key: string, value: any): ThenPromise<boolean>;

    get(key: string): ThenPromise<any>;

    rm(key: string): ThenPromise<boolean>;

    exists(key: string): ThenPromise<boolean>;

    dump(): ThenPromise<{name: string, data: any[]}>;
}

Usage:

const storage = new UnifiedStorage();
const storage2 = new UnifiedStorage("test", new FilesystemStorageAdapter("./data", "test"));

storage.set("key", "value")
    .then((data) => {
        ...
    })
    .catch((err) => {
        ...
    })

...

storage.get("key")
    .then((data) => {
       ...
    })
    .catch((err) => {
      ...
    });
0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago