vargai 0.4.0-alpha76 → 0.4.0-alpha77
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/package.json
CHANGED
|
@@ -85,7 +85,13 @@ function serializeValue(v: unknown): string {
|
|
|
85
85
|
return v;
|
|
86
86
|
}
|
|
87
87
|
if (v instanceof Uint8Array) {
|
|
88
|
-
|
|
88
|
+
// Hash binary data instead of base64-encoding to keep cache keys small.
|
|
89
|
+
// Raw base64 can produce 65-110KB strings for audio segments, exceeding
|
|
90
|
+
// Upstash Redis' 32KB key size limit.
|
|
91
|
+
return `uint8:${v.byteLength}:${Bun.hash(v).toString(16)}`;
|
|
92
|
+
}
|
|
93
|
+
if (isVargElement(v)) {
|
|
94
|
+
return `element:${computeCacheKey(v).join(":")}`;
|
|
89
95
|
}
|
|
90
96
|
if (Array.isArray(v)) {
|
|
91
97
|
return `[${v.map(serializeValue).join(",")}]`;
|
|
@@ -128,7 +134,7 @@ export function computeCacheKey(element: VargElement): CacheKeyPart[] {
|
|
|
128
134
|
} else if (v === null || v === undefined) {
|
|
129
135
|
key.push(k, v);
|
|
130
136
|
} else if (v instanceof Uint8Array) {
|
|
131
|
-
key.push(k,
|
|
137
|
+
key.push(k, `uint8:${v.byteLength}:${Bun.hash(v).toString(16)}`);
|
|
132
138
|
} else if (isVargElement(v)) {
|
|
133
139
|
key.push(k, ...computeCacheKey(v));
|
|
134
140
|
} else if (Array.isArray(v) || typeof v === "object") {
|