0.34.0 • Published 5 months ago

@sphereon/ssi-sdk.kv-store-temp v0.34.0

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
5 months ago

Veramo Key Value store

A simple typed Key Value store with out of the box support for in memory/maps, sqlite and typeorm implementations for usage in browser, NodeJS and React-Native. It includes a tiered local/remote implementation that support all environments.

Usage in your application or module

setup

Veramo provides 3 store adapters out of the box. The first is an in memory Map based store, the second is a TypeORM based store, meaning we support multiple databases. Lastly there is a tiered store, which allows you to use a local and remote store together.

You should also be able to use store adapters from the keyv project. Be aware that Veramo uses an internal fork of that project, as we have several constraints not present in the upstream project. As a result the adapters are not guaranteed to work in your environment. See Keyv project relationship for more information.

Map based in memory store

This is the simplest implementation where a Map is being used to store the Keys and Values

import { IKeyValueStore, IKeyValueStoreOptions, KeyValueStore } from '@veramo/key-value-store'

const options: IKeyValueStoreOptions<MyValueType> = {
  namespace: 'example',
  store: new Map<string, MyValueType>(),
}
const kvStore: IKeyValueStore<MyValueType> = new KeyValueStore({ options })

TypeORM store

This implementation uses TypeORM using a simple entity to store the namespace prefixed key, an expiration value and the value itself. It supports multiple database backends.

import { IKeyValueStore, IKeyValueStoreOptions, KeyValueStore, KeyValueStoreEntity, KeyValueTypeORMStoreAdapter } from '@veramo/key-value-store'
import { DataSource } from 'typeorm'

const dbConnection: DataSource = await new DataSource({
  type: 'sqlite',
  database: ':memory:',
  logging: 'all',
  migrationsRun: true,
  synchronize: false,
  entities: [KeyValueStoreEntity],
}).initialize()

const options: IKeyValueStoreOptions<MyValueType> = {
  namespace: 'example',
  store: new KeyValueTypeORMStoreAdapter({ dbConnection }),
}
const kvStore: IKeyValueStore<MyValueType> = new KeyValueStore({ options })

Tiered store

The tiered store expects a local store and a remote store. Obviously it makes most sense to have a memory based local store and potentially more expensive/slower remote store

import {
  kvStoreMigrations,
  IKeyValueStore,
  IKeyValueStoreOptions,
  KeyValueStore,
  KeyValueStoreEntity,
  KeyValueTieredStoreAdapter,
  KeyValueTypeORMStoreAdapter,
} from '@veramo/key-value-store'
import { DataSource } from 'typeorm'

dbConnection = await new DataSource({
  type: 'sqlite',
  database: ':memory:',
  logging: 'all',
  migrationsRun: true,
  synchronize: false,
  migrations: [...kvStoreMigrations],
  entities: [KeyValueStoreEntity],
}).initialize()

const local: Map<string, MyValueType> = new Map()
const remote = new KeyValueTypeORMStoreAdapter({ dbConnection })

const options: IKeyValueStoreOptions<MyValueType> = {
  namespace: 'example',
  store: new KeyValueTieredStoreAdapter({ local, remote }),
}
const kvStore: IKeyValueStore<MyValueType> = new KeyValueStore<MyValueType>({ options })

Usage

After you have setup the Key Value Store as described above in your agent, it will be available in your agent.

kvStore.set('hello', { example: world }) // Stores the value object by key untill deleted
kvStore.set('expiring', { example: 'expiration' }, 1000) // Stores the value object by key for 1 second
const value = await kvStore.get('hello') // { example: world }
const values = await kvStore.getMany(['hello', 'expiring']) // [{ example: world }, {example: expiring}]

if (await kvStore.has('hello')) {
  await kvStore.delete('hello') // return a boolean for success. You can also call it on non existing keys, which will return false
}

await kvStore.clear() // Removes all keys/values from the store
kvStore.disconnect() // disconnects the store from it backing adapter. You cannot reuse the store afterwards unlesss you initialize a new store.

Keyv project relationship

Please note that a large portion of the Veramo Key Value Store code is a port of the keyv project, adding support for Typescript and ESM, so it can be used Veramo

The ported code should support the storage plugins available for the keyv project, although testing has been limited Veramo itself has a requirement to support NodeJS, Browser and React-Native environments. The port and the store adapters included in Veramo run in these environments. Please be aware that these requirements probably aren't true for any keyv storage plugins.

One of the big changes compared to the upstream project is that this port does not have dynamic loading of adapters based on URIs. We believe that any Veramo Key Value store should use explicit defined adapters.

The keyv port is part of the Veramo Key Value Store module code itself, as we do not want to make an official maintained port at this point.

Veramo exposes its own API/interfaces for the Key Value store, meaning we could also support any other implementation in the future

We welcome any new storage modules

0.30.2-next.394

11 months ago

0.30.2-next.395

11 months ago

0.30.2-fix.364

11 months ago

0.30.2-fix.363

11 months ago

0.30.2-fix.368

11 months ago

0.30.2-fix.367

11 months ago

0.30.2-next.373

11 months ago

0.31.1-fix.4

11 months ago

0.31.1-fix.5

11 months ago

0.33.0

8 months ago

0.30.2-next.148

12 months ago

0.30.2-next.145

12 months ago

0.31.1-next.4

11 months ago

0.30.2-next.390

11 months ago

0.31.0

11 months ago

0.30.2-next.191

12 months ago

0.30.2-fix.199

12 months ago

0.30.2-fix.198

12 months ago

0.30.2-next.328

11 months ago

0.30.2-next.329

11 months ago

0.32.1-next.291

8 months ago

0.32.1-next.287

8 months ago

0.30.2-fix.395

11 months ago

0.30.2-fix.393

11 months ago

0.30.2-next.365

11 months ago

0.30.2-next.367

11 months ago

0.30.2-next.362

11 months ago

0.30.2-next.363

11 months ago

0.30.2-fix.139

12 months ago

0.30.2-fix.140

12 months ago

0.31.1-fix.20

11 months ago

0.30.2-next.276

12 months ago

0.30.2-next.279

12 months ago

0.30.2-next.273

12 months ago

0.30.2-next.275

12 months ago

0.30.2-next.281

12 months ago

0.32.0

11 months ago

0.30.2-next.285

11 months ago

0.30.2-next.259

12 months ago

0.32.1-next.113

9 months ago

0.30.2-next.269

12 months ago

0.30.2-next.267

12 months ago

0.31.1-next.44

11 months ago

0.31.1-next.42

11 months ago

0.31.1-next.41

11 months ago

0.31.1-next.39

11 months ago

0.31.1-next.33

11 months ago

0.31.1-next.32

11 months ago

0.32.1-fix.160

9 months ago

0.31.1-next.30

11 months ago

0.32.1-next.161

9 months ago

0.30.2-next.297

11 months ago

0.33.1-next.3

6 months ago

0.33.1-next.2

6 months ago

0.31.1-next.62

11 months ago

0.32.1-next.54

9 months ago

0.32.1-next.157

9 months ago

0.31.1-next.60

11 months ago

0.32.1-next.150

9 months ago

0.32.1-next.141

9 months ago

0.32.1-next.145

9 months ago

0.33.1-next.73

5 months ago

0.32.1-fix.143

9 months ago

0.32.1-fix.142

9 months ago

0.33.1-next.68

6 months ago

0.30.2-next.200

12 months ago

0.31.1-next.29

11 months ago

0.31.1-next.26

11 months ago

0.31.1-next.28

11 months ago

0.31.1-next.21

11 months ago

0.31.1-next.24

11 months ago

0.31.1-next.23

11 months ago

0.31.1-next.19

11 months ago

0.31.1-next.14

11 months ago

0.31.1-next.17

11 months ago

0.31.1-next.13

11 months ago

0.34.0

5 months ago

0.30.2-fix.278

12 months ago

0.30.2-fix.270

12 months ago

0.30.2-fix.280

12 months ago

0.30.2-next.215

12 months ago

0.30.2-next.221

12 months ago

0.30.2-next.223

12 months ago

0.30.2-fix.266

12 months ago

0.30.2-fix.265

12 months ago

0.30.2-fix.263

12 months ago

0.30.2-fix.262

12 months ago

0.32.1-fix.15

11 months ago

0.32.1-next.13

11 months ago

0.32.1-next.17

11 months ago

0.32.1-next.18

10 months ago

0.32.1-next.12

11 months ago

0.32.1-next.20

10 months ago

0.30.2-fix.138

12 months ago

0.30.2-next.133

12 months ago

0.30.2-next.135

12 months ago

0.30.2-fix.136

12 months ago

0.30.2-next.129

1 year ago

0.30.2-next.125

1 year ago

0.30.2-next.103

1 year ago

0.30.2-fix.50

1 year ago

0.30.2-fix.48

1 year ago

0.30.2-fix.49

1 year ago

0.30.2-next.58

1 year ago

0.30.2-next.66

1 year ago

0.30.2-next.47

1 year ago

0.30.2-next.4

1 year ago

0.30.2-next.5

1 year ago

0.30.2-next.6

1 year ago

0.29.1-next.185

1 year ago

0.30.1

1 year ago

0.29.1-next.175

1 year ago

0.29.1-next.174

1 year ago

0.29.1-next.177

1 year ago

0.29.1-next.176

1 year ago

0.27.1-next.20

1 year ago

0.27.1-next.24

1 year ago

0.27.1-next.25

1 year ago

0.29.1-next.80

1 year ago

0.27.1-next.28

1 year ago

0.27.1-next.29

1 year ago

0.27.1-next.26

1 year ago

0.29.1-next.82

1 year ago

0.28.1-next.51

1 year ago

0.28.1-next.50

1 year ago

0.28.1-next.53

1 year ago

0.28.1-next.52

1 year ago

0.27.1-next.31

1 year ago

0.27.1-next.33

1 year ago

0.27.1-next.39

1 year ago

0.27.1-next.38

1 year ago

0.28.1-next.48

1 year ago

0.28.1-next.49

1 year ago

0.28.1-next.44

1 year ago

0.29.1-next.5

1 year ago

0.28.1-next.40

1 year ago

0.26.1-next.6

1 year ago

0.29.1-next.4

1 year ago

0.26.1-next.4

1 year ago

0.29.1-next.2

1 year ago

0.28.1-next.41

1 year ago

0.26.1-next.140

1 year ago

0.29.1-next.61

1 year ago

0.28.1-next.60

1 year ago

0.26.1-next.129

1 year ago

0.26.1-next.127

1 year ago

0.26.1-next.131

1 year ago

0.26.1-next.132

1 year ago

0.26.1-next.115

1 year ago

0.26.1-next.113

1 year ago

0.26.1-next.108

1 year ago

0.26.1-next.106

1 year ago

0.25.0

1 year ago

0.27.1-next.8

1 year ago

0.27.1-next.9

1 year ago

0.27.1-next.6

1 year ago

0.27.1-next.7

1 year ago

0.27.1-next.4

1 year ago

0.27.1-next.2

1 year ago

0.26.0

1 year ago

0.28.1-next.11

1 year ago

0.28.1-next.10

1 year ago

0.28.1-next.13

1 year ago

0.25.1-next.118

1 year ago

0.28.1-next.39

1 year ago

0.24.0

1 year ago

0.29.0

1 year ago

0.24.1-next.98

1 year ago

0.27.0

1 year ago

0.24.1-next.42

1 year ago

0.28.0

1 year ago

0.29.1-next.122

1 year ago

0.25.1-next.29

1 year ago

0.25.1-next.28

1 year ago

0.28.1-next.9

1 year ago

0.28.1-next.5

1 year ago

0.28.1-next.6

1 year ago

0.28.1-next.8

1 year ago

0.23.5-next.24

1 year ago

0.29.1-next.104

1 year ago

0.29.1-next.103

1 year ago

0.29.1-next.47

1 year ago

0.29.1-next.46

1 year ago

0.29.1-next.106

1 year ago

0.29.1-next.105

1 year ago

0.24.1-next.100

1 year ago

0.27.1-next.10

1 year ago

0.27.1-next.12

1 year ago

0.24.1-next.113

1 year ago

0.24.1-next.112

1 year ago

0.24.1-next.118

1 year ago

0.24.1-next.116

1 year ago

0.23.5-next.22

1 year ago

0.23.5-next.12

1 year ago

0.23.5-next.11

1 year ago

0.23.5-next.10

2 years ago

0.23.1-next.7

2 years ago

0.23.3-next.3

2 years ago

0.23.4

2 years ago

0.23.2-next.4

2 years ago

0.23.1-next.2

2 years ago

0.23.0

2 years ago

0.21.2-next.25

2 years ago

0.21.2-next.23

2 years ago

0.21.2-next.8

2 years ago

0.21.2-next.7

2 years ago

0.21.2-next.6

2 years ago

0.21.2-next.17

2 years ago

0.22.0

2 years ago

0.21.1-next.8

2 years ago

0.21.1-next.4

2 years ago

0.19.1-next.125

2 years ago

0.19.1-next.126

2 years ago

0.21.0

2 years ago

0.19.1-next.119

2 years ago

0.19.1-next.135

2 years ago

0.21.1-next.2

2 years ago

0.19.1-next.117

2 years ago

0.19.1-next.113

2 years ago

0.19.1-next.114

2 years ago

0.19.1-next.115

2 years ago

0.19.1-next.116

2 years ago

0.19.1-next.111

2 years ago

0.19.1-next.112

2 years ago

0.19.1-next.105

2 years ago

0.19.1-next.110

2 years ago

0.19.1-next.106

2 years ago

0.19.1-next.108

2 years ago

0.19.1-next.109

2 years ago

0.19.1-next.98

2 years ago

0.19.1-next.99

2 years ago

0.19.1-next.102

2 years ago

0.19.1-next.100

2 years ago

0.19.1-next.101

2 years ago

0.19.1-next.96

2 years ago

0.19.1-next.75

2 years ago

0.19.1-next.2

2 years ago

0.19.1-next.24

2 years ago

0.19.0

2 years ago

0.18.2-next.96

2 years ago

0.18.2-next.95

2 years ago

0.18.2-next.94

2 years ago

0.18.2-next.92

2 years ago

0.18.2-next.58

2 years ago

0.18.2-next.62

2 years ago

0.18.2-next.77

2 years ago

0.18.2-next.57

2 years ago

0.18.2-next.47

2 years ago

0.18.2-next.15

2 years ago

0.18.2-next.17

2 years ago

0.18.2-next.14

2 years ago

0.18.2-next.12

2 years ago

0.18.2-next.9

2 years ago

0.18.2-next.3

2 years ago

0.18.1

2 years ago

0.18.1-next.8

2 years ago

0.18.1-next.3

2 years ago

0.18.1-next.2

2 years ago

0.18.1-next.4

2 years ago

0.17.6-next.61

2 years ago

0.18.0

2 years ago

0.17.6-next.58

2 years ago

0.17.6-next.57

2 years ago

0.17.6-next.56

2 years ago

0.17.6-next.52

2 years ago

0.17.2

2 years ago

0.17.3

2 years ago

0.17.4

2 years ago

0.17.5

2 years ago

0.16.1-next.3

2 years ago

0.17.0

2 years ago

0.17.1

2 years ago

0.17.2-next.2

2 years ago

0.17.2-next.4

2 years ago

0.15.2-next.96

2 years ago

0.15.2-next.95

2 years ago

0.15.2-next.97

2 years ago

0.13.1-next.3

2 years ago

0.13.1-next.4

2 years ago

0.13.1-next.5

2 years ago

0.13.1-next.6

2 years ago

0.13.1-next.7

2 years ago

0.13.1-next.8

2 years ago

0.13.1-next.32

2 years ago

0.17.1-next.2

2 years ago

0.13.1-next.33

2 years ago

0.15.0

2 years ago

0.15.1

2 years ago

0.13.1-next.17

2 years ago

0.13.1-next.14

2 years ago

0.13.1-next.15

2 years ago

0.13.1-next.10

2 years ago

0.13.1-next.18

2 years ago

0.16.0

2 years ago

0.13.1-next.27

2 years ago

0.13.1-next.28

2 years ago

0.13.1-next.25

2 years ago

0.13.1-next.26

2 years ago

0.13.1-next.23

2 years ago

0.13.1-next.24

2 years ago

0.15.1-next.2

2 years ago

0.17.3-next.2

2 years ago

0.15.2-next.39

2 years ago

0.15.2-next.32

2 years ago

0.15.2-next.33

2 years ago

0.15.2-next.113

2 years ago

0.15.2-next.110

2 years ago

0.15.2-next.111

2 years ago

0.17.6-next.7

2 years ago

0.17.6-next.6

2 years ago

0.17.6-next.9

2 years ago

0.17.6-next.3

2 years ago

0.17.6-next.2

2 years ago

0.17.6-next.5

2 years ago

0.17.6-next.4

2 years ago

0.14.2-next.28

2 years ago

0.14.2-next.27

2 years ago

0.14.2-next.29

2 years ago

0.14.2-next.23

2 years ago

0.15.2-next.103

2 years ago

0.14.2-next.26

2 years ago

0.15.2-next.104

2 years ago

0.14.2-next.25

2 years ago

0.14.0

2 years ago

0.15.2-next.109

2 years ago

0.14.1

2 years ago

0.15.2-next.124

2 years ago

0.15.2-next.121

2 years ago

0.15.2-next.29

2 years ago

0.14.2-next.18

2 years ago

0.15.2-next.116

2 years ago

0.15.2-next.117

2 years ago

0.15.2-next.114

2 years ago

0.14.2-next.14

2 years ago

0.15.2-next.118

2 years ago

0.14.2-next.40

2 years ago

0.15.2-next.4

2 years ago

0.15.2-next.5

2 years ago

0.15.2-next.6

2 years ago

0.14.2-next.49

2 years ago

0.14.2-next.45

2 years ago

0.14.2-next.48

2 years ago

0.14.2-next.47

2 years ago

0.14.2-next.42

2 years ago

0.15.2-next.77

2 years ago

0.14.2-next.41

2 years ago

0.14.2-next.43

2 years ago

0.15.2-next.101

2 years ago

0.14.2-next.39

2 years ago

0.14.2-next.38

2 years ago

0.14.1-next.2

2 years ago

0.14.2-next.35

2 years ago

0.14.2-next.34

2 years ago

0.14.2-next.37

2 years ago

0.14.2-next.36

2 years ago

0.14.2-next.31

2 years ago

0.14.2-next.30

2 years ago

0.14.2-next.33

2 years ago

0.14.2-next.32

2 years ago

0.14.2-next.51

2 years ago

0.14.2-next.50

2 years ago

0.17.6-next.16

2 years ago

0.15.2-next.3

2 years ago

0.14.2-next.58

2 years ago

0.13.0

2 years ago

0.12.1-next.21

2 years ago

0.12.1-next.20

2 years ago

0.12.1-next.19

2 years ago

0.12.0

2 years ago

0.11.1-next.154

2 years ago

0.11.1-next.153

2 years ago

0.11.1-next.152

2 years ago

0.11.1-next.162

2 years ago

0.11.1-next.151

2 years ago

0.11.1-next.150

2 years ago

0.11.1-next.149

2 years ago

0.11.1-next.148

2 years ago

0.11.1-next.147

2 years ago

0.11.1-next.146

2 years ago

0.11.1-next.145

2 years ago

0.11.1-next.144

2 years ago

0.11.1-next.142

2 years ago

0.11.1-next.141

2 years ago

0.11.1-next.140

2 years ago

0.11.1-next.131

2 years ago

0.11.1-next.112

2 years ago

0.11.1-next.106

2 years ago

0.11.1-next.72

2 years ago

0.11.1-next.70

2 years ago