mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-10-07 22:57:07 +00:00
feat: allow local cache to be pass as option
This commit is contained in:
2
API.md
2
API.md
@@ -75,6 +75,8 @@ Creates and returns an instance of OrbitDB. Use the optional `directory` argumen
|
||||
|
||||
- `keystore` (Keystore Instance) : By default creates an instance of [Keystore](https://github.com/orbitdb/orbit-db-keystore). A custom keystore instance can be used, see [this](https://github.com/orbitdb/orbit-db/blob/master/test/utils/custom-test-keystore.js) for an example.
|
||||
|
||||
- 'cache' (Cache Instance) : By default creates an instance of [Cache](https://github.com/orbitdb/orbit-db-cache). A custom cache instance can also be used.
|
||||
|
||||
After creating an `OrbitDB` instance , you can access the different data stores. Creating a database instance, eg. with `orbitdb.keyvalue(...)`, returns a *Promise* that resolves to a [database instance](#store-api). See the [Store](#store-api) section for details of common methods and properties.
|
||||
|
||||
*For further details, see usage for [kvstore](https://github.com/orbitdb/orbit-db-kvstore#usage), [eventlog](https://github.com/orbitdb/orbit-db-eventstore#usage), [feed](https://github.com/orbitdb/orbit-db-feedstore#usage), [docstore](https://github.com/orbitdb/orbit-db-docstore#usage) and [counter](https://github.com/orbitdb/orbit-db-counterstore#usage).*
|
||||
|
||||
@@ -37,6 +37,7 @@ class OrbitDB {
|
||||
this.stores = {}
|
||||
this.directory = directory || './orbitdb'
|
||||
this.keystore = options.keystore || Keystore.create(path.join(this.directory, this.id, '/keystore'))
|
||||
this.cache = options.cache || Cache
|
||||
this.key = this.keystore.getKey(this.id) || this.keystore.createKey(this.id)
|
||||
this._directConnections = {}
|
||||
}
|
||||
@@ -348,7 +349,7 @@ class OrbitDB {
|
||||
async _loadCache (directory, dbAddress) {
|
||||
let cache
|
||||
try {
|
||||
cache = await Cache.load(directory, dbAddress)
|
||||
cache = await this.cache.load(directory, dbAddress)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
logger.error("Couldn't load Cache:", e)
|
||||
|
||||
Reference in New Issue
Block a user