@blazetrails/solid-cache 0.0.0-stage → 0.1.0-alpha0.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/LICENSE +21 -0
- package/dist/active-support/cache/solid-cache-store.d.ts +2 -0
- package/dist/active-support/cache/solid-cache-store.js +4 -0
- package/dist/active-support/cache/solid-cache-store.js.map +1 -0
- package/dist/configuration.d.ts +31 -0
- package/dist/configuration.js +60 -0
- package/dist/configuration.js.map +1 -0
- package/dist/connections/sharded.d.ts +16 -0
- package/dist/connections/sharded.js +45 -0
- package/dist/connections/sharded.js.map +1 -0
- package/dist/connections/single.d.ts +12 -0
- package/dist/connections/single.js +29 -0
- package/dist/connections/single.js.map +1 -0
- package/dist/connections/unmanaged.d.ts +10 -0
- package/dist/connections/unmanaged.js +24 -0
- package/dist/connections/unmanaged.js.map +1 -0
- package/dist/connections.d.ts +10 -0
- package/dist/connections.js +37 -0
- package/dist/connections.js.map +1 -0
- package/dist/constants.generated.d.ts +2 -0
- package/dist/constants.generated.js +53 -0
- package/dist/constants.generated.js.map +1 -0
- package/dist/constants.solid-cache-install-install-generator.generated.d.ts +2 -0
- package/dist/constants.solid-cache-install-install-generator.generated.js +4 -0
- package/dist/constants.solid-cache-install-install-generator.generated.js.map +1 -0
- package/dist/engine.d.ts +19 -0
- package/dist/engine.js +59 -0
- package/dist/engine.js.map +1 -0
- package/dist/entry/encryption.d.ts +10 -0
- package/dist/entry/encryption.js +12 -0
- package/dist/entry/encryption.js.map +1 -0
- package/dist/entry/expiration.d.ts +23 -0
- package/dist/entry/expiration.js +53 -0
- package/dist/entry/expiration.js.map +1 -0
- package/dist/entry/size/estimate.d.ts +38 -0
- package/dist/entry/size/estimate.js +91 -0
- package/dist/entry/size/estimate.js.map +1 -0
- package/dist/entry/size/moving-average-estimate.d.ts +29 -0
- package/dist/entry/size/moving-average-estimate.js +55 -0
- package/dist/entry/size/moving-average-estimate.js.map +1 -0
- package/dist/entry/size.d.ts +16 -0
- package/dist/entry/size.js +31 -0
- package/dist/entry/size.js.map +1 -0
- package/dist/entry.d.ts +55 -0
- package/dist/entry.js +137 -0
- package/dist/entry.js.map +1 -0
- package/dist/expiry-job.d.ts +10 -0
- package/dist/expiry-job.js +14 -0
- package/dist/expiry-job.js.map +1 -0
- package/dist/generators/solid-cache/install/install-generator.d.ts +16 -0
- package/dist/generators/solid-cache/install/install-generator.js +62 -0
- package/dist/generators/solid-cache/install/install-generator.js.map +1 -0
- package/dist/generators/solid-cache/install/templates/config/cache.ts.tt +25 -0
- package/dist/generators/solid-cache/install/templates/config/cache.ts.tt.js +23 -0
- package/dist/generators/solid-cache/install/templates/db/cache_schema.ts.tt +16 -0
- package/dist/generators/solid-cache/install/templates/db/cache_schema.ts.tt.js +12 -0
- package/dist/generators/solid-cache/install/templates/db/cache_structure.mysql.sql +56 -0
- package/dist/generators/solid-cache/install/templates/db/cache_structure.postgresql.sql +128 -0
- package/dist/generators/solid-cache/install/templates/db/cache_structure.sqlite3.sql +6 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/maglev-hash.d.ts +38 -0
- package/dist/maglev-hash.js +80 -0
- package/dist/maglev-hash.js.map +1 -0
- package/dist/record.d.ts +12 -0
- package/dist/record.js +55 -0
- package/dist/record.js.map +1 -0
- package/dist/solid-cache.d.ts +27 -0
- package/dist/solid-cache.js +11 -0
- package/dist/solid-cache.js.map +1 -0
- package/dist/store/api.d.ts +52 -0
- package/dist/store/api.js +178 -0
- package/dist/store/api.js.map +1 -0
- package/dist/store/connections.d.ts +38 -0
- package/dist/store/connections.js +65 -0
- package/dist/store/connections.js.map +1 -0
- package/dist/store/entries.d.ts +26 -0
- package/dist/store/entries.js +57 -0
- package/dist/store/entries.js.map +1 -0
- package/dist/store/execution.d.ts +15 -0
- package/dist/store/execution.js +53 -0
- package/dist/store/execution.js.map +1 -0
- package/dist/store/expiry.d.ts +10 -0
- package/dist/store/expiry.js +38 -0
- package/dist/store/expiry.js.map +1 -0
- package/dist/store/failsafe.d.ts +16 -0
- package/dist/store/failsafe.js +35 -0
- package/dist/store/failsafe.js.map +1 -0
- package/dist/store/stats.d.ts +19 -0
- package/dist/store/stats.js +29 -0
- package/dist/store/stats.js.map +1 -0
- package/dist/store.d.ts +69 -0
- package/dist/store.js +130 -0
- package/dist/store.js.map +1 -0
- package/package.json +60 -3
- package/README.md +0 -3
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export declare class Estimate {
|
|
2
|
+
readonly samples: number;
|
|
3
|
+
maxRecords: number;
|
|
4
|
+
size: number;
|
|
5
|
+
private _outlierSizeAndCutoff?;
|
|
6
|
+
private _nonOutlierEstimatedSize?;
|
|
7
|
+
private _sampledFraction?;
|
|
8
|
+
private _sampledNonOutlierSize?;
|
|
9
|
+
private _sampleRangeSize?;
|
|
10
|
+
protected constructor({ samples }: {
|
|
11
|
+
samples: number;
|
|
12
|
+
});
|
|
13
|
+
static new({ samples }: {
|
|
14
|
+
samples: number;
|
|
15
|
+
}): Promise<Estimate>;
|
|
16
|
+
isExact(): Promise<boolean>;
|
|
17
|
+
/** @internal */
|
|
18
|
+
private outliersSize;
|
|
19
|
+
/** @internal */
|
|
20
|
+
private outliersCount;
|
|
21
|
+
/** @internal */
|
|
22
|
+
private outliersCutoff;
|
|
23
|
+
/** @internal */
|
|
24
|
+
private outliersSizeCountAndCutoff;
|
|
25
|
+
/** @internal */
|
|
26
|
+
private nonOutlierEstimatedSize;
|
|
27
|
+
/** @internal */
|
|
28
|
+
private sampledFraction;
|
|
29
|
+
/** @internal */
|
|
30
|
+
private sampledNonOutlierSize;
|
|
31
|
+
/** @internal */
|
|
32
|
+
private sampleRange;
|
|
33
|
+
/** @internal */
|
|
34
|
+
private keyHashRange;
|
|
35
|
+
/** @internal */
|
|
36
|
+
private sampleRangeSize;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=estimate.d.ts.map
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { sql } from "@blazetrails/arel";
|
|
2
|
+
import { Kernel, Range } from "@blazetrails/ruby-compat";
|
|
3
|
+
import { SolidCache } from "../../solid-cache.js";
|
|
4
|
+
export class Estimate {
|
|
5
|
+
samples;
|
|
6
|
+
maxRecords;
|
|
7
|
+
size;
|
|
8
|
+
_outlierSizeAndCutoff;
|
|
9
|
+
_nonOutlierEstimatedSize;
|
|
10
|
+
_sampledFraction;
|
|
11
|
+
_sampledNonOutlierSize;
|
|
12
|
+
_sampleRangeSize;
|
|
13
|
+
constructor({ samples }) {
|
|
14
|
+
this.samples = samples;
|
|
15
|
+
}
|
|
16
|
+
static async new({ samples }) {
|
|
17
|
+
const estimate = new Estimate({ samples });
|
|
18
|
+
estimate.maxRecords ??= Number(await SolidCache.Entry.idRange());
|
|
19
|
+
estimate.size = (await estimate.outliersSize()) + (await estimate.nonOutlierEstimatedSize());
|
|
20
|
+
return estimate;
|
|
21
|
+
}
|
|
22
|
+
async isExact() {
|
|
23
|
+
return (await this.outliersCount()) < this.samples || (await this.sampledFraction()) === 1;
|
|
24
|
+
}
|
|
25
|
+
/** @internal */
|
|
26
|
+
async outliersSize() {
|
|
27
|
+
return (await this.outliersSizeCountAndCutoff())[0];
|
|
28
|
+
}
|
|
29
|
+
/** @internal */
|
|
30
|
+
async outliersCount() {
|
|
31
|
+
return (await this.outliersSizeCountAndCutoff())[1];
|
|
32
|
+
}
|
|
33
|
+
/** @internal */
|
|
34
|
+
async outliersCutoff() {
|
|
35
|
+
return (await this.outliersSizeCountAndCutoff())[2];
|
|
36
|
+
}
|
|
37
|
+
/** @internal */
|
|
38
|
+
outliersSizeCountAndCutoff() {
|
|
39
|
+
return (this._outlierSizeAndCutoff ??= Promise.resolve(SolidCache.Entry.uncached(async () => {
|
|
40
|
+
const [sum, count, min] = (await SolidCache.Entry.largestByteSizes(this.samples).pick(sql("sum(byte_size), count(*), min(byte_size)")));
|
|
41
|
+
return sum != null ? [Number(sum), Number(count), min] : [0, 0, null];
|
|
42
|
+
})));
|
|
43
|
+
}
|
|
44
|
+
/** @internal */
|
|
45
|
+
async nonOutlierEstimatedSize() {
|
|
46
|
+
const sampledFraction = await this.sampledFraction();
|
|
47
|
+
return (this._nonOutlierEstimatedSize ??=
|
|
48
|
+
sampledFraction === 0
|
|
49
|
+
? 0
|
|
50
|
+
: Math.round((await this.sampledNonOutlierSize()) / sampledFraction));
|
|
51
|
+
}
|
|
52
|
+
/** @internal */
|
|
53
|
+
async sampledFraction() {
|
|
54
|
+
const maxRecords = this.maxRecords;
|
|
55
|
+
return (this._sampledFraction ??=
|
|
56
|
+
maxRecords <= this.samples ? 0 : Math.min(this.samples / (maxRecords - this.samples), 1));
|
|
57
|
+
}
|
|
58
|
+
/** @internal */
|
|
59
|
+
async sampledNonOutlierSize() {
|
|
60
|
+
if (this._sampledNonOutlierSize != null)
|
|
61
|
+
return this._sampledNonOutlierSize;
|
|
62
|
+
const sampleRange = await this.sampleRange();
|
|
63
|
+
const outliersCutoff = await this.outliersCutoff();
|
|
64
|
+
return (this._sampledNonOutlierSize = Number(await SolidCache.Entry.uncached(() => SolidCache.Entry.inKeyHashRange(sampleRange)
|
|
65
|
+
.upToByteSize(outliersCutoff)
|
|
66
|
+
.sum("byte_size"))));
|
|
67
|
+
}
|
|
68
|
+
/** @internal */
|
|
69
|
+
async sampleRange() {
|
|
70
|
+
if ((await this.sampledFraction()) === 1) {
|
|
71
|
+
return this.keyHashRange();
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
const sampleRangeSize = await this.sampleRangeSize();
|
|
75
|
+
const begin = this.keyHashRange().begin;
|
|
76
|
+
const end = this.keyHashRange().end;
|
|
77
|
+
const start = begin + Kernel.rand(end - sampleRangeSize - begin + 1n);
|
|
78
|
+
return new Range(start, start + sampleRangeSize);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/** @internal */
|
|
82
|
+
keyHashRange() {
|
|
83
|
+
return SolidCache.Entry.KEY_HASH_ID_RANGE;
|
|
84
|
+
}
|
|
85
|
+
/** @internal */
|
|
86
|
+
async sampleRangeSize() {
|
|
87
|
+
const size = this.keyHashRange().end - this.keyHashRange().begin + 1n;
|
|
88
|
+
return (this._sampleRangeSize ??= BigInt(Math.trunc(Number(size) * (await this.sampledFraction()))));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=estimate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"estimate.js","sourceRoot":"","sources":["../../../lib/entry/size/estimate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,MAAM,OAAO,QAAQ;IACV,OAAO,CAAS;IACzB,UAAU,CAAU;IACpB,IAAI,CAAU;IACN,qBAAqB,CAAsC;IAC3D,wBAAwB,CAAU;IAClC,gBAAgB,CAAU;IAC1B,sBAAsB,CAAU;IAChC,gBAAgB,CAAU;IAElC,YAAsB,EAAE,OAAO,EAAuB;QACpD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,OAAO,EAAuB;QAC/C,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;QAC3C,QAAQ,CAAC,UAAU,KAAK,MAAM,CAAC,MAAM,UAAU,CAAC,KAAM,CAAC,OAAO,EAAE,CAAC,CAAC;QAClE,QAAQ,CAAC,IAAI,GAAG,CAAC,MAAM,QAAQ,CAAC,YAAY,EAAE,CAAC,GAAG,CAAC,MAAM,QAAQ,CAAC,uBAAuB,EAAE,CAAC,CAAC;QAC7F,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,OAAO;QACX,OAAO,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N,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,eAAe,EAAE,CAAC;YACrD,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC,KAAe,CAAC;YAClD,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC,GAAa,CAAC;YAC9C,MAAM,KAAK,GAAG,KAAK,GAAI,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,eAAe,GAAG,KAAK,GAAG,EAAE,CAAY,CAAC;YAClF,OAAO,IAAI,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,eAAe,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;IAED,gBAAgB;IACR,YAAY;QAClB,OAAO,UAAU,CAAC,KAAM,CAAC,iBAAiB,CAAC;IAC7C,CAAC;IAED,gBAAgB;IACR,KAAK,CAAC,eAAe;QAC3B,MAAM,IAAI,GAAI,IAAI,CAAC,YAAY,EAAE,CAAC,GAAc,GAAI,IAAI,CAAC,YAAY,EAAE,CAAC,KAAgB,GAAG,EAAE,CAAC;QAC9F,OAAO,CAAC,IAAI,CAAC,gBAAgB,KAAK,MAAM,CACtC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC,CAC1D,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export declare class MovingAverageEstimate {
|
|
2
|
+
static readonly ESTIMATES_KEY = "__solid_cache_entry_size_moving_average_estimates";
|
|
3
|
+
static readonly MAX_RETAINED_ESTIMATES = 50;
|
|
4
|
+
static readonly TARGET_SAMPLED_FRACTION = 0.0005;
|
|
5
|
+
readonly samples: number;
|
|
6
|
+
size: number;
|
|
7
|
+
/** @internal */
|
|
8
|
+
private estimate;
|
|
9
|
+
protected constructor({ samples }: {
|
|
10
|
+
samples: number;
|
|
11
|
+
});
|
|
12
|
+
static new({ samples }: {
|
|
13
|
+
samples: number;
|
|
14
|
+
}): Promise<MovingAverageEstimate>;
|
|
15
|
+
isExact(): Promise<boolean>;
|
|
16
|
+
/** @internal */
|
|
17
|
+
private previousValues;
|
|
18
|
+
/** @internal */
|
|
19
|
+
private latestValue;
|
|
20
|
+
/** @internal */
|
|
21
|
+
private latestValues;
|
|
22
|
+
/** @internal */
|
|
23
|
+
private writeValues;
|
|
24
|
+
/** @internal */
|
|
25
|
+
private retainedEstimates;
|
|
26
|
+
/** @internal */
|
|
27
|
+
private retainedEstimatesForTargetFraction;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=moving-average-estimate.d.ts.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { isPresent } from "@blazetrails/activesupport";
|
|
2
|
+
import { SolidCache } from "../../solid-cache.js";
|
|
3
|
+
import { Estimate } from "./estimate.js";
|
|
4
|
+
const decoder = new TextDecoder();
|
|
5
|
+
export class MovingAverageEstimate {
|
|
6
|
+
static ESTIMATES_KEY = "__solid_cache_entry_size_moving_average_estimates";
|
|
7
|
+
static MAX_RETAINED_ESTIMATES = 50;
|
|
8
|
+
static TARGET_SAMPLED_FRACTION = 0.0005;
|
|
9
|
+
samples;
|
|
10
|
+
size;
|
|
11
|
+
/** @internal */
|
|
12
|
+
estimate;
|
|
13
|
+
constructor({ samples }) {
|
|
14
|
+
this.samples = samples;
|
|
15
|
+
}
|
|
16
|
+
static async new({ samples }) {
|
|
17
|
+
const self = new MovingAverageEstimate({ samples });
|
|
18
|
+
self.estimate = await Estimate.new({ samples: samples });
|
|
19
|
+
const values = await self.latestValues();
|
|
20
|
+
self.size = Math.round(values.reduce((a, b) => a + b, 0) / values.length);
|
|
21
|
+
await self.writeValues(values);
|
|
22
|
+
return self;
|
|
23
|
+
}
|
|
24
|
+
isExact() {
|
|
25
|
+
return this.estimate.isExact();
|
|
26
|
+
}
|
|
27
|
+
/** @internal */
|
|
28
|
+
async previousValues() {
|
|
29
|
+
const read = await SolidCache.Entry.read(MovingAverageEstimate.ESTIMATES_KEY);
|
|
30
|
+
const value = read instanceof Uint8Array ? decoder.decode(read) : read;
|
|
31
|
+
return isPresent(value) ? value.split("|").map((v) => parseInt(v, 10) || 0) : [];
|
|
32
|
+
}
|
|
33
|
+
/** @internal */
|
|
34
|
+
latestValue() {
|
|
35
|
+
return this.estimate.size;
|
|
36
|
+
}
|
|
37
|
+
/** @internal */
|
|
38
|
+
async latestValues() {
|
|
39
|
+
return [...(await this.previousValues()), this.latestValue()].slice(-(await this.retainedEstimates()));
|
|
40
|
+
}
|
|
41
|
+
/** @internal */
|
|
42
|
+
async writeValues(values) {
|
|
43
|
+
await SolidCache.Entry.write(MovingAverageEstimate.ESTIMATES_KEY, values.join("|"));
|
|
44
|
+
}
|
|
45
|
+
/** @internal */
|
|
46
|
+
async retainedEstimates() {
|
|
47
|
+
return Math.min(await this.retainedEstimatesForTargetFraction(), MovingAverageEstimate.MAX_RETAINED_ESTIMATES);
|
|
48
|
+
}
|
|
49
|
+
/** @internal */
|
|
50
|
+
async retainedEstimatesForTargetFraction() {
|
|
51
|
+
return (Math.floor(Math.floor(this.estimate.maxRecords / this.samples) *
|
|
52
|
+
MovingAverageEstimate.TARGET_SAMPLED_FRACTION) + 1);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=moving-average-estimate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"moving-average-estimate.js","sourceRoot":"","sources":["../../../lib/entry/size/moving-average-estimate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAElC,MAAM,OAAO,qBAAqB;IAChC,MAAM,CAAU,aAAa,GAAG,mDAAmD,CAAC;IACpF,MAAM,CA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AAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACpF,CAAC;IAED,gBAAgB;IACR,WAAW;QACjB,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;IAC5B,CAAC;IAED,gBAAgB;IACR,KAAK,CAAC,YAAY;QACxB,OAAO,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,KAAK,CACjE,CAAC,CAAC,MAAM,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAClC,CAAC;IACJ,CAAC;IAED,gBAAgB;IACR,KAAK,CAAC,WAAW,CAAC,MAAgB;QACxC,MAAM,UAAU,CAAC,KAAM,CAAC,KAAK,CAAC,qBAAqB,CAAC,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACvF,CAAC;IAED,gBAAgB;IACR,KAAK,CAAC,iBAAiB;QAC7B,OAAO,IAAI,CAAC,GAAG,CACb,MAAM,IAAI,CAAC,kCAAkC,EAAE,EAC/C,qBAAqB,CAAC,sBAAsB,CAC7C,CAAC;IACJ,CAAC;IAED,gBAAgB;IACR,KAAK,CAAC,kCAAkC;QAC9C,OAAO,CACL,IAAI,CAAC,KAAK,CACR,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC;YACjD,qBAAqB,CAAC,uBAAuB,CAChD,GAAG,CAAC,CACN,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { classModule } from "@blazetrails/ruby-compat";
|
|
2
|
+
import type { Entry } from "../entry.js";
|
|
3
|
+
import { Estimate } from "./size/estimate.js";
|
|
4
|
+
import { MovingAverageEstimate } from "./size/moving-average-estimate.js";
|
|
5
|
+
export declare class ClassMethods {
|
|
6
|
+
static estimatedSize(this: typeof Entry, { samples }?: {
|
|
7
|
+
samples?: number;
|
|
8
|
+
}): Promise<number>;
|
|
9
|
+
}
|
|
10
|
+
export declare class Size {
|
|
11
|
+
static readonly [classModule] = true;
|
|
12
|
+
static ClassMethods: typeof ClassMethods;
|
|
13
|
+
static Estimate: typeof Estimate;
|
|
14
|
+
static MovingAverageEstimate: typeof MovingAverageEstimate;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=size.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Concern, extend } from "@blazetrails/activesupport";
|
|
2
|
+
import { classModule } from "@blazetrails/ruby-compat";
|
|
3
|
+
import { SolidCache } from "../solid-cache.js";
|
|
4
|
+
import { Estimate } from "./size/estimate.js";
|
|
5
|
+
import { MovingAverageEstimate } from "./size/moving-average-estimate.js";
|
|
6
|
+
export class ClassMethods {
|
|
7
|
+
static async estimatedSize({ samples = SolidCache.configuration.sizeEstimateSamples } = {}) {
|
|
8
|
+
return (await MovingAverageEstimate.new({ samples: samples })).size;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export class Size {
|
|
12
|
+
static [classModule] = true;
|
|
13
|
+
static Estimate;
|
|
14
|
+
static MovingAverageEstimate;
|
|
15
|
+
}
|
|
16
|
+
extend(Size, Concern);
|
|
17
|
+
Object.defineProperty(Size, "ClassMethods", { value: ClassMethods });
|
|
18
|
+
Size.Estimate = Estimate;
|
|
19
|
+
Size.MovingAverageEstimate = MovingAverageEstimate;
|
|
20
|
+
Size.included(null, function () {
|
|
21
|
+
this.scope("largestByteSizes", function (limit) {
|
|
22
|
+
return this.from(this.order({ byte_size: "desc" }).limit(limit).select("byte_size"));
|
|
23
|
+
});
|
|
24
|
+
this.scope("inKeyHashRange", function (range) {
|
|
25
|
+
return this.where({ key_hash: range });
|
|
26
|
+
});
|
|
27
|
+
this.scope("upToByteSize", function (cutoff) {
|
|
28
|
+
return this.where("byte_size <= ?", cutoff);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=size.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"size.js","sourceRoot":"","sources":["../../lib/entry/size.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAE1E,MAAM,OAAO,YAAY;IACvB,MAAM,CAAC,KAAK,CAAC,aAAa,CAExB,EAAE,OAAO,GAAG,UAAU,CAAC,aAAa,CAAC,mBAAmB,EAAE,GAAyB,EAAE;QAErF,OAAO,CAAC,MAAM,qBAAqB,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACtE,CAAC;CACF;AAED,MAAM,OAAO,IAAI;IACf,MAAM,CAAU,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC;IAErC,MAAM,CAAC,QAAQ,CAAkB;IACjC,MAAM,CAAC,qBAAqB,CAA+B;CAC5D;AACD,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACtB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,cAAc,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC;AACrE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;AACzB,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;AAEjD,IAGD,CAAC,QAAQ,CAAC,IAAI,EAAE;IACf,IAAI,CAAC,KAAK,CAAC,kBAAkB,EAAE,UAAiC,KAAa;QAC3E,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC;IACvF,CAAC,CAAC,CAAC;IACH,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE,UAAiC,KAAc;QAC1E,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;IACH,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,UAAiC,MAAe;QACzE,OAAO,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/entry.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type ClassMethods as ExpirationClassMethods } from "./entry/expiration.js";
|
|
2
|
+
import { type ClassMethods as SizeClassMethods } from "./entry/size.js";
|
|
3
|
+
import { type Relation } from "@blazetrails/activerecord";
|
|
4
|
+
import { Range, Hash } from "@blazetrails/ruby-compat";
|
|
5
|
+
import { Record } from "./record.js";
|
|
6
|
+
type Payload = {
|
|
7
|
+
key: string | Uint8Array;
|
|
8
|
+
value: unknown;
|
|
9
|
+
keyHash?: number | bigint;
|
|
10
|
+
byteSize?: number;
|
|
11
|
+
};
|
|
12
|
+
export declare class Entry extends Record {
|
|
13
|
+
static readonly ESTIMATED_ROW_OVERHEAD = 140;
|
|
14
|
+
static readonly ESTIMATED_ENCRYPTION_OVERHEAD = 170;
|
|
15
|
+
static readonly KEY_HASH_ID_RANGE: Range<bigint>;
|
|
16
|
+
static readonly MULTI_BATCH_SIZE = 1000;
|
|
17
|
+
/** @internal */
|
|
18
|
+
static _selectSql: Map<number, string> | undefined;
|
|
19
|
+
static expire: typeof ExpirationClassMethods.expire;
|
|
20
|
+
/** @internal */
|
|
21
|
+
static isCacheFull: typeof ExpirationClassMethods.isCacheFull;
|
|
22
|
+
/** @internal */
|
|
23
|
+
static expiryCandidateIds: typeof ExpirationClassMethods.expiryCandidateIds;
|
|
24
|
+
static estimatedSize: typeof SizeClassMethods.estimatedSize;
|
|
25
|
+
static largestByteSizes: (limit: number) => Relation<Entry>;
|
|
26
|
+
static inKeyHashRange: (range: unknown) => Relation<Entry>;
|
|
27
|
+
static upToByteSize: (cutoff: unknown) => Relation<Entry>;
|
|
28
|
+
static write(key: string | Uint8Array, value: unknown): Promise<void>;
|
|
29
|
+
static writeMulti(payloads: Payload[]): Promise<void>;
|
|
30
|
+
static read(key: string | Uint8Array): Promise<unknown>;
|
|
31
|
+
static readMulti(keys: (string | Uint8Array)[]): Promise<Hash<string | Uint8Array, unknown>>;
|
|
32
|
+
static deleteByKey(...keys: (string | Uint8Array)[]): Promise<number>;
|
|
33
|
+
static clearTruncate(): Promise<unknown>;
|
|
34
|
+
static clearDelete(): Promise<unknown>;
|
|
35
|
+
static lockAndWrite(key: string | Uint8Array, block: (value: unknown) => unknown | Promise<unknown>): Promise<unknown>;
|
|
36
|
+
static idRange(): Promise<unknown>;
|
|
37
|
+
/** @internal */
|
|
38
|
+
private static addKeyHashAndByteSize;
|
|
39
|
+
/** @internal */
|
|
40
|
+
private static upsertUniqueBy;
|
|
41
|
+
/** @internal */
|
|
42
|
+
private static selectSql;
|
|
43
|
+
/** @internal */
|
|
44
|
+
private static keyHashFor;
|
|
45
|
+
/** @internal */
|
|
46
|
+
private static keyHashesFor;
|
|
47
|
+
/** @internal */
|
|
48
|
+
private static byteSizeFor;
|
|
49
|
+
/** @internal */
|
|
50
|
+
private static estimatedRowOverhead;
|
|
51
|
+
/** @internal */
|
|
52
|
+
private static withoutQueryCache;
|
|
53
|
+
}
|
|
54
|
+
export {};
|
|
55
|
+
//# sourceMappingURL=entry.d.ts.map
|
package/dist/entry.js
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { include, runLoadHooks } from "@blazetrails/activesupport";
|
|
2
|
+
import { Encryption } from "./entry/encryption.js";
|
|
3
|
+
import { Expiration } from "./entry/expiration.js";
|
|
4
|
+
import { Size } from "./entry/size.js";
|
|
5
|
+
import { sql } from "@blazetrails/arel";
|
|
6
|
+
import { constSet, Range, Digest, eachSlice, Hash, b, rbEqual, toS, unpack, } from "@blazetrails/ruby-compat";
|
|
7
|
+
import { Record } from "./record.js";
|
|
8
|
+
import { SolidCache } from "./solid-cache.js";
|
|
9
|
+
export class Entry extends Record {
|
|
10
|
+
static ESTIMATED_ROW_OVERHEAD = 140;
|
|
11
|
+
static ESTIMATED_ENCRYPTION_OVERHEAD = 170;
|
|
12
|
+
static KEY_HASH_ID_RANGE = new Range(-(2n ** 63n), 2n ** 63n - 1n);
|
|
13
|
+
static MULTI_BATCH_SIZE = 1000;
|
|
14
|
+
static {
|
|
15
|
+
constSet(SolidCache, "Entry", this);
|
|
16
|
+
constSet(this, "Encryption", Encryption);
|
|
17
|
+
constSet(this, "Expiration", Expiration);
|
|
18
|
+
constSet(this, "Size", Size);
|
|
19
|
+
include(this, Encryption);
|
|
20
|
+
include(this, Expiration);
|
|
21
|
+
include(this, Size);
|
|
22
|
+
}
|
|
23
|
+
static async write(key, value) {
|
|
24
|
+
await this.writeMulti([{ key: key, value: value }]);
|
|
25
|
+
}
|
|
26
|
+
static async writeMulti(payloads) {
|
|
27
|
+
await this.withoutQueryCache(async () => {
|
|
28
|
+
for (const payloadBatch of eachSlice(payloads, Entry.MULTI_BATCH_SIZE)) {
|
|
29
|
+
await this.upsertAll(this.addKeyHashAndByteSize(payloadBatch), {
|
|
30
|
+
uniqueBy: (await this.upsertUniqueBy()) ?? undefined,
|
|
31
|
+
onDuplicate: ":update",
|
|
32
|
+
updateOnly: ["key", "value", "byte_size"],
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
static async read(key) {
|
|
38
|
+
return (await this.readMulti([key])).get(key) ?? null;
|
|
39
|
+
}
|
|
40
|
+
static async readMulti(keys) {
|
|
41
|
+
return await this.withoutQueryCache(async () => {
|
|
42
|
+
const results = new Hash();
|
|
43
|
+
for (const keysBatch of eachSlice(keys, Entry.MULTI_BATCH_SIZE)) {
|
|
44
|
+
const query = sql(this.selectSql(keysBatch), ...this.keyHashesFor(keysBatch));
|
|
45
|
+
await this.withConnection(async (connection) => {
|
|
46
|
+
const rows = (await connection.selectAll(query, "SolidCache::Entry Load")).castValues(this.attributeTypes());
|
|
47
|
+
for (const [key, value] of rows)
|
|
48
|
+
results.set(key, value);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return results;
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
static async deleteByKey(...keys) {
|
|
55
|
+
return await this.withoutQueryCache(() => this.where({ key_hash: this.keyHashesFor(keys) }).deleteAll());
|
|
56
|
+
}
|
|
57
|
+
static async clearTruncate() {
|
|
58
|
+
return await this.withConnection(async (connection) => {
|
|
59
|
+
return await connection.truncate(this.tableName);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
static async clearDelete() {
|
|
63
|
+
return await this.withoutQueryCache(() => this.inBatches().deleteAll());
|
|
64
|
+
}
|
|
65
|
+
static async lockAndWrite(key, block) {
|
|
66
|
+
return await this.transaction(async () => {
|
|
67
|
+
return await this.withoutQueryCache(async () => {
|
|
68
|
+
const result = (await this.lock()
|
|
69
|
+
.where({ key_hash: this.keyHashFor(key) })
|
|
70
|
+
.pick("key", "value"));
|
|
71
|
+
const newValue = await block(result != null && rbEqual(result[0], key) ? result[1] : null);
|
|
72
|
+
if (newValue != null && newValue !== false)
|
|
73
|
+
await this.write(key, newValue);
|
|
74
|
+
return newValue;
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
static async idRange() {
|
|
79
|
+
return await this.withoutQueryCache(async () => (await this.pick(sql("max(id) - min(id) + 1"))) ?? 0);
|
|
80
|
+
}
|
|
81
|
+
/** @internal */
|
|
82
|
+
static addKeyHashAndByteSize(payloads) {
|
|
83
|
+
return payloads.map((payload) => {
|
|
84
|
+
const dup = { ...payload };
|
|
85
|
+
dup.key_hash = this.keyHashFor(payload.key);
|
|
86
|
+
dup.byte_size = this.byteSizeFor(payload);
|
|
87
|
+
return dup;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/** @internal */
|
|
91
|
+
static async upsertUniqueBy() {
|
|
92
|
+
return await this.withConnection(async (connection) => {
|
|
93
|
+
return (await connection.supportsInsertConflictTarget()) ? "key_hash" : null;
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
/** @internal */
|
|
97
|
+
static selectSql(keys) {
|
|
98
|
+
if (!Object.hasOwn(this, "_selectSql"))
|
|
99
|
+
this._selectSql = new Map();
|
|
100
|
+
let selectSql = this._selectSql.get(keys.length);
|
|
101
|
+
if (selectSql == null) {
|
|
102
|
+
selectSql = this.where({ key_hash: [1111, 2222] })
|
|
103
|
+
.select(":key", ":value")
|
|
104
|
+
.toSql()
|
|
105
|
+
.replaceAll("1111, 2222", Array.from({ length: keys.length }, () => "?").join(", "));
|
|
106
|
+
this._selectSql.set(keys.length, selectSql);
|
|
107
|
+
}
|
|
108
|
+
return selectSql;
|
|
109
|
+
}
|
|
110
|
+
/** @internal */
|
|
111
|
+
static keyHashFor(key) {
|
|
112
|
+
return unpack(Digest.SHA256.digest(toS(key)), "q>")[0];
|
|
113
|
+
}
|
|
114
|
+
/** @internal */
|
|
115
|
+
static keyHashesFor(keys) {
|
|
116
|
+
return keys.map((key) => this.keyHashFor(key));
|
|
117
|
+
}
|
|
118
|
+
/** @internal */
|
|
119
|
+
static byteSizeFor(payload) {
|
|
120
|
+
return b(toS(payload.key)).length + b(toS(payload.value)).length + this.estimatedRowOverhead();
|
|
121
|
+
}
|
|
122
|
+
/** @internal */
|
|
123
|
+
static estimatedRowOverhead() {
|
|
124
|
+
if (SolidCache.configuration.isEncrypt()) {
|
|
125
|
+
return Entry.ESTIMATED_ROW_OVERHEAD + Entry.ESTIMATED_ENCRYPTION_OVERHEAD;
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
return Entry.ESTIMATED_ROW_OVERHEAD;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/** @internal */
|
|
132
|
+
static withoutQueryCache(block) {
|
|
133
|
+
return Promise.resolve(this.uncached(block, { dirties: false }));
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
runLoadHooks("solid_cache_entry", Entry);
|
|
137
|
+
//# sourceMappingURL=entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry.js","sourceRoot":"","sources":["../lib/entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,UAAU,EAA+C,MAAM,uBAAuB,CAAC;AAChG,OAAO,EAAE,IAAI,EAAyC,MAAM,iBAAiB,CAAC;AAE9E,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EACL,QAAQ,EACR,KAAK,EACL,MAAM,EACN,SAAS,EACT,IAAI,EACJ,CAAC,EACD,OAAO,EACP,GAAG,EACH,MAAM,GACP,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAS9C,MAAM,OAAO,KAAM,SAAQ,MAAM;IAC/B,MAAM,CAAU,sBAAsB,GAAG,GAAG,CAAC;IAE7C,MAAM,CAAU,6BAA6B,GAAG,GAAG,CAAC;IAEpD,MAAM,CAAU,iBAAiB,GAAG,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE,EAAE,IAAI,GAAG,GAAG,EAAE,CAAC,CAA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AA2B;QAC7D,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IACnE,CAAC;CACF;AAED,YAAY,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Base } from "@blazetrails/activejob";
|
|
2
|
+
export declare class ExpiryJob extends Base {
|
|
3
|
+
perform(count: number, { shard, maxAge, maxEntries, maxSize, }?: {
|
|
4
|
+
shard?: string | null;
|
|
5
|
+
maxAge?: unknown;
|
|
6
|
+
maxEntries?: unknown;
|
|
7
|
+
maxSize?: unknown;
|
|
8
|
+
}): Promise<unknown>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=expiry-job.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Base } from "@blazetrails/activejob";
|
|
2
|
+
import { constSet } from "@blazetrails/ruby-compat";
|
|
3
|
+
import { Entry } from "./entry.js";
|
|
4
|
+
import { Record } from "./record.js";
|
|
5
|
+
import { SolidCache } from "./solid-cache.js";
|
|
6
|
+
export class ExpiryJob extends Base {
|
|
7
|
+
static {
|
|
8
|
+
constSet(SolidCache, "ExpiryJob", this);
|
|
9
|
+
}
|
|
10
|
+
async perform(count, { shard = null, maxAge = null, maxEntries = null, maxSize = null, } = {}) {
|
|
11
|
+
return await Record.withShard(shard, () => Entry.expire(count, { maxAge: maxAge, maxEntries: maxEntries, maxSize: maxSize }));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=expiry-job.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expiry-job.js","sourceRoot":"","sources":["../lib/expiry-job.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,OAAO,SAAU,SAAQ,IAAI;IACjC;QACE,QAAQ,CAAC,UAAU,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,OAAO,CACX,KAAa,EACb,EACE,KAAK,GAAG,IAAI,EACZ,MAAM,GAAG,IAAI,EACb,UAAU,GAAG,IAAI,EACjB,OAAO,GAAG,IAAI,GACf,GAAyF,EAAE;QAE5F,OAAO,MAAM,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,CACxC,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAClF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import "../../../constants.solid-cache-install-install-generator.generated.js";
|
|
2
|
+
import type * as ThorActions from "@blazetrails/thor/actions";
|
|
3
|
+
import { Base } from "@blazetrails/trailties/generators";
|
|
4
|
+
export declare class InstallGenerator extends Base {
|
|
5
|
+
copyFile: OmitThisParameter<typeof ThorActions.Actions.copyFile>;
|
|
6
|
+
/** @missingRailsArgs template — CONVERGEABLE solid-cache-install-generator-writes-cache-yml */
|
|
7
|
+
copyFiles(): Promise<void>;
|
|
8
|
+
configureCacheStoreAdapter(): Promise<void>;
|
|
9
|
+
/** @internal */
|
|
10
|
+
private copySqlSchemaForAdapter;
|
|
11
|
+
/** @internal */
|
|
12
|
+
private sqlSchemaFileForAdapter;
|
|
13
|
+
/** @internal */
|
|
14
|
+
private raiseUnsupportedAdapterError;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=install-generator.d.ts.map
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import "../../../constants.solid-cache-install-install-generator.generated.js";
|
|
2
|
+
import { Base as ActiveRecordBase } from "@blazetrails/activerecord";
|
|
3
|
+
import { File, Pathname, RuntimeError, rbInspect } from "@blazetrails/ruby-compat";
|
|
4
|
+
import { Trails } from "@blazetrails/trailties";
|
|
5
|
+
import { Base } from "@blazetrails/trailties/generators";
|
|
6
|
+
export class InstallGenerator extends Base {
|
|
7
|
+
static {
|
|
8
|
+
this.sourceRoot(File.expandPath("templates", decodeURIComponent(new URL(".", import.meta.url).pathname)));
|
|
9
|
+
this.methodAdded("copyFiles");
|
|
10
|
+
this.methodAdded("configureCacheStoreAdapter");
|
|
11
|
+
}
|
|
12
|
+
/** @missingRailsArgs template — CONVERGEABLE solid-cache-install-generator-writes-cache-yml */
|
|
13
|
+
async copyFiles() {
|
|
14
|
+
await this.template("config/cache.ts");
|
|
15
|
+
if (Trails.application.config.activeRecord.schemaFormat === "sql") {
|
|
16
|
+
await this.copySqlSchemaForAdapter();
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
await this.template("db/cache_schema.ts");
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
async configureCacheStoreAdapter() {
|
|
23
|
+
await this.gsubFile(new Pathname(this.destinationRoot).join("config/environments/production.ts"), /(\/\/ )?this\.config\.cacheStore = (".*")/, 'this.config.cacheStore = ":solid_cache_store"');
|
|
24
|
+
}
|
|
25
|
+
/** @internal */
|
|
26
|
+
async copySqlSchemaForAdapter() {
|
|
27
|
+
const sqlFile = this.sqlSchemaFileForAdapter();
|
|
28
|
+
if (sqlFile != null) {
|
|
29
|
+
await this.copyFile(sqlFile, "db/cache_structure.sql");
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
this.raiseUnsupportedAdapterError();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/** @internal */
|
|
36
|
+
sqlSchemaFileForAdapter() {
|
|
37
|
+
switch (ActiveRecordBase.connectionDbConfig().adapter) {
|
|
38
|
+
case "postgresql":
|
|
39
|
+
return "db/cache_structure.postgresql.sql";
|
|
40
|
+
case "mysql2":
|
|
41
|
+
case "trilogy":
|
|
42
|
+
return "db/cache_structure.mysql.sql";
|
|
43
|
+
case "sqlite3":
|
|
44
|
+
return "db/cache_structure.sqlite3.sql";
|
|
45
|
+
default:
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/** @internal */
|
|
50
|
+
raiseUnsupportedAdapterError() {
|
|
51
|
+
const errorMessage = `
|
|
52
|
+
ERROR: Unsupported database adapter for SQL schema format: ${rbInspect(ActiveRecordBase.connectionDbConfig().adapter)}
|
|
53
|
+
|
|
54
|
+
SolidCache supports installing for the following Rails adapters with schema_format = :sql:
|
|
55
|
+
- PostgreSQL (postgresql)
|
|
56
|
+
- MySQL (mysql2, trilogy)
|
|
57
|
+
- SQLite (sqlite3)
|
|
58
|
+
`;
|
|
59
|
+
throw new RuntimeError(errorMessage);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=install-generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install-generator.js","sourceRoot":"","sources":["../../../../lib/generators/solid-cache/install/install-generator.ts"],"names":[],"mappings":"AAAA,OAAO,uEAAuE,CAAC;AAC/E,OAAO,EAAE,IAAI,IAAI,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAEnF,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAEhD,OAAO,EAAE,IAAI,EAAE,MAAM,mCAAmC,CAAC;AAEzD,MAAM,OAAO,gBAAiB,SAAQ,IAAI;IACxC;QACE,IAAI,CAAC,UAAU,CACb,IAAI,CAAC,UAAU,CAAC,WAAW,EAAE,kBAAkB,CAAC,IAAI,GAAG,CAAC,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K,SAAS;gBACZ,OAAO,gCAAgC,CAAC;YAC1C;gBACE,OAAO,IAAI,CAAC;QAChB,CAAC;IACH,CAAC;IAED,gBAAgB;IACR,4BAA4B;QAClC,MAAM,YAAY,GAAG;6DACoC,SAAS,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,CAAC,OAAO,CAAC;;;;;;CAMpH,CAAC;QAEE,MAAM,IAAI,YAAY,CAAC,YAAY,CAAC,CAAC;IACvC,CAAC;CACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Trails } from "@blazetrails/trailties";
|
|
2
|
+
|
|
3
|
+
const defaults = {
|
|
4
|
+
database: <%= JSON.stringify(Object.hasOwn(ENV, "DATABASE") ? ENV.DATABASE : "cache") %>,
|
|
5
|
+
storeOptions: {
|
|
6
|
+
// Cap age of oldest cache entry to fulfill retention policies
|
|
7
|
+
// maxAge: 60 * 24 * 60 * 60,
|
|
8
|
+
maxSize: 256 * 1024 * 1024,
|
|
9
|
+
namespace: Trails.env.toString(),
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
development: {
|
|
15
|
+
...defaults,
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
test: {
|
|
19
|
+
...defaults,
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
production: {
|
|
23
|
+
...defaults,
|
|
24
|
+
},
|
|
25
|
+
};
|