hypercore 10.28.0 → 10.28.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +6 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -56,7 +56,7 @@ module.exports = class Hypercore extends EventEmitter {
|
|
|
56
56
|
this.replicator = null
|
|
57
57
|
this.encryption = null
|
|
58
58
|
this.extensions = new Map()
|
|
59
|
-
this.cache =
|
|
59
|
+
this.cache = createCache(opts.cache)
|
|
60
60
|
|
|
61
61
|
this.valueEncoding = null
|
|
62
62
|
this.encodeBatch = null
|
|
@@ -296,6 +296,7 @@ module.exports = class Hypercore extends EventEmitter {
|
|
|
296
296
|
|
|
297
297
|
if (!isFirst) await opts._opening
|
|
298
298
|
if (opts.preload) opts = { ...opts, ...(await this._retryPreload(opts.preload)) }
|
|
299
|
+
if (this.cache === null && opts.cache) this.cache = createCache(opts.cache)
|
|
299
300
|
|
|
300
301
|
if (isFirst) {
|
|
301
302
|
await this._openCapabilities(key, storage, opts)
|
|
@@ -1116,3 +1117,7 @@ function ensureEncryption (core, opts) {
|
|
|
1116
1117
|
if (core.encryption && b4a.equals(core.encryption.key, opts.encryptionKey)) return
|
|
1117
1118
|
core.encryption = new BlockEncryption(opts.encryptionKey, core.key, { compat: core.core.compat, isBlockKey: opts.isBlockKey })
|
|
1118
1119
|
}
|
|
1120
|
+
|
|
1121
|
+
function createCache (cache) {
|
|
1122
|
+
return cache === true ? new Xache({ maxSize: 65536, maxAge: 0 }) : (cache || null)
|
|
1123
|
+
}
|