s3db.js 8.0.1 → 8.0.2
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/PLUGINS.md +114 -39
- package/README.md +1 -25
- package/dist/s3db.cjs.js +67 -23
- package/dist/s3db.cjs.min.js +1 -1
- package/dist/s3db.es.js +67 -23
- package/dist/s3db.es.min.js +1 -1
- package/dist/s3db.iife.js +67 -23
- package/dist/s3db.iife.min.js +1 -1
- package/package.json +1 -1
- package/src/plugins/cache/memory-cache.class.js +2 -2
- package/src/plugins/cache.plugin.js +75 -21
package/dist/s3db.es.js
CHANGED
|
@@ -6623,8 +6623,8 @@ class MemoryCache extends Cache {
|
|
|
6623
6623
|
super(config);
|
|
6624
6624
|
this.cache = {};
|
|
6625
6625
|
this.meta = {};
|
|
6626
|
-
this.maxSize = config.maxSize
|
|
6627
|
-
this.ttl = config.ttl
|
|
6626
|
+
this.maxSize = config.maxSize !== void 0 ? config.maxSize : 1e3;
|
|
6627
|
+
this.ttl = config.ttl !== void 0 ? config.ttl : 3e5;
|
|
6628
6628
|
}
|
|
6629
6629
|
async _set(key, data) {
|
|
6630
6630
|
if (this.maxSize > 0 && Object.keys(this.cache).length >= this.maxSize) {
|
|
@@ -7482,37 +7482,81 @@ class PartitionAwareFilesystemCache extends FilesystemCache {
|
|
|
7482
7482
|
class CachePlugin extends plugin_class_default {
|
|
7483
7483
|
constructor(options = {}) {
|
|
7484
7484
|
super(options);
|
|
7485
|
-
this.
|
|
7486
|
-
this.
|
|
7487
|
-
|
|
7488
|
-
|
|
7489
|
-
|
|
7490
|
-
|
|
7491
|
-
|
|
7492
|
-
|
|
7485
|
+
this.driverName = options.driver || "s3";
|
|
7486
|
+
this.ttl = options.ttl;
|
|
7487
|
+
this.maxSize = options.maxSize;
|
|
7488
|
+
this.config = options.config || {};
|
|
7489
|
+
this.includePartitions = options.includePartitions !== false;
|
|
7490
|
+
this.partitionStrategy = options.partitionStrategy || "hierarchical";
|
|
7491
|
+
this.partitionAware = options.partitionAware !== false;
|
|
7492
|
+
this.trackUsage = options.trackUsage !== false;
|
|
7493
|
+
this.preloadRelated = options.preloadRelated !== false;
|
|
7494
|
+
this.legacyConfig = {
|
|
7495
|
+
memoryOptions: options.memoryOptions,
|
|
7496
|
+
filesystemOptions: options.filesystemOptions,
|
|
7497
|
+
s3Options: options.s3Options,
|
|
7498
|
+
driver: options.driver
|
|
7493
7499
|
};
|
|
7494
7500
|
}
|
|
7495
7501
|
async setup(database) {
|
|
7496
7502
|
await super.setup(database);
|
|
7497
7503
|
}
|
|
7498
7504
|
async onSetup() {
|
|
7499
|
-
if (this.
|
|
7500
|
-
this.driver = this.
|
|
7501
|
-
} else if (this.
|
|
7502
|
-
|
|
7503
|
-
|
|
7504
|
-
|
|
7505
|
+
if (this.driverName && typeof this.driverName === "object") {
|
|
7506
|
+
this.driver = this.driverName;
|
|
7507
|
+
} else if (this.driverName === "memory") {
|
|
7508
|
+
const driverConfig = {
|
|
7509
|
+
...this.legacyConfig.memoryOptions,
|
|
7510
|
+
// Legacy support (lowest priority)
|
|
7511
|
+
...this.config
|
|
7512
|
+
// New config format (medium priority)
|
|
7513
|
+
};
|
|
7514
|
+
if (this.ttl !== void 0) {
|
|
7515
|
+
driverConfig.ttl = this.ttl;
|
|
7516
|
+
}
|
|
7517
|
+
if (this.maxSize !== void 0) {
|
|
7518
|
+
driverConfig.maxSize = this.maxSize;
|
|
7519
|
+
}
|
|
7520
|
+
this.driver = new memory_cache_class_default(driverConfig);
|
|
7521
|
+
} else if (this.driverName === "filesystem") {
|
|
7522
|
+
const driverConfig = {
|
|
7523
|
+
...this.legacyConfig.filesystemOptions,
|
|
7524
|
+
// Legacy support (lowest priority)
|
|
7525
|
+
...this.config
|
|
7526
|
+
// New config format (medium priority)
|
|
7527
|
+
};
|
|
7528
|
+
if (this.ttl !== void 0) {
|
|
7529
|
+
driverConfig.ttl = this.ttl;
|
|
7530
|
+
}
|
|
7531
|
+
if (this.maxSize !== void 0) {
|
|
7532
|
+
driverConfig.maxSize = this.maxSize;
|
|
7533
|
+
}
|
|
7534
|
+
if (this.partitionAware) {
|
|
7505
7535
|
this.driver = new PartitionAwareFilesystemCache({
|
|
7506
|
-
partitionStrategy: this.
|
|
7507
|
-
trackUsage: this.
|
|
7508
|
-
preloadRelated: this.
|
|
7509
|
-
...
|
|
7536
|
+
partitionStrategy: this.partitionStrategy,
|
|
7537
|
+
trackUsage: this.trackUsage,
|
|
7538
|
+
preloadRelated: this.preloadRelated,
|
|
7539
|
+
...driverConfig
|
|
7510
7540
|
});
|
|
7511
7541
|
} else {
|
|
7512
|
-
this.driver = new FilesystemCache(
|
|
7542
|
+
this.driver = new FilesystemCache(driverConfig);
|
|
7513
7543
|
}
|
|
7514
7544
|
} else {
|
|
7515
|
-
|
|
7545
|
+
const driverConfig = {
|
|
7546
|
+
client: this.database.client,
|
|
7547
|
+
// Required for S3Cache
|
|
7548
|
+
...this.legacyConfig.s3Options,
|
|
7549
|
+
// Legacy support (lowest priority)
|
|
7550
|
+
...this.config
|
|
7551
|
+
// New config format (medium priority)
|
|
7552
|
+
};
|
|
7553
|
+
if (this.ttl !== void 0) {
|
|
7554
|
+
driverConfig.ttl = this.ttl;
|
|
7555
|
+
}
|
|
7556
|
+
if (this.maxSize !== void 0) {
|
|
7557
|
+
driverConfig.maxSize = this.maxSize;
|
|
7558
|
+
}
|
|
7559
|
+
this.driver = new s3_cache_class_default(driverConfig);
|
|
7516
7560
|
}
|
|
7517
7561
|
this.installDatabaseHooks();
|
|
7518
7562
|
this.installResourceHooks();
|
|
@@ -13380,7 +13424,7 @@ class Database extends EventEmitter {
|
|
|
13380
13424
|
super();
|
|
13381
13425
|
this.version = "1";
|
|
13382
13426
|
this.s3dbVersion = (() => {
|
|
13383
|
-
const [ok, err, version] = try_fn_default(() => true ? "8.0.
|
|
13427
|
+
const [ok, err, version] = try_fn_default(() => true ? "8.0.2" : "latest");
|
|
13384
13428
|
return ok ? version : "latest";
|
|
13385
13429
|
})();
|
|
13386
13430
|
this.resources = {};
|