@orieljs/cache 0.1.0-alpha.14 → 0.1.0-alpha.16
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/dist/index.d.ts +67 -13
- package/dist/index.js +182 -41
- package/dist/index.js.map +1 -1
- package/package.json +16 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _orieljs_contracts from '@orieljs/contracts';
|
|
2
|
-
import { OrielError, Lock, CacheRepository, DatabaseConnection, CacheManager as CacheManager$1, Container, RateLimiter as RateLimiter$1 } from '@orieljs/contracts';
|
|
3
|
-
import Redis from 'ioredis';
|
|
2
|
+
import { OrielError, Lock, CacheRepository, DatabaseConnection, CacheManager as CacheManager$1, Container, RateLimiter as RateLimiter$1, RateLimiterCallback, RateLimit, ConsoleKernel, Application } from '@orieljs/contracts';
|
|
3
|
+
import { Redis } from 'ioredis';
|
|
4
4
|
import * as _orieljs_support from '@orieljs/support';
|
|
5
5
|
import { ServiceProvider } from '@orieljs/support';
|
|
6
6
|
|
|
@@ -191,6 +191,10 @@ declare class DatabaseStore implements Store {
|
|
|
191
191
|
increment(key: string, by: number, attempt?: number): Promise<number>;
|
|
192
192
|
decrement(key: string, by: number): Promise<number>;
|
|
193
193
|
forget(key: string): Promise<boolean>;
|
|
194
|
+
/**
|
|
195
|
+
* Deletes this store's keys: those starting with its prefix (every row without one). The prefix's `%` and `_` are
|
|
196
|
+
* escaped, so another app's keys in the same table, `appXcache_…` beside `app_cache_…`, stay.
|
|
197
|
+
*/
|
|
194
198
|
flush(): Promise<boolean>;
|
|
195
199
|
}
|
|
196
200
|
|
|
@@ -255,15 +259,32 @@ interface RedisConfig {
|
|
|
255
259
|
}
|
|
256
260
|
/**
|
|
257
261
|
* Builds an ioredis client from cache.stores.redis config: a prebuilt client, or a URL and/or raw ioredis
|
|
258
|
-
* options. With a URL, the remaining options (db, password, lazyConnect...) are still passed through.
|
|
262
|
+
* options. With a URL, the remaining options (db, password, lazyConnect...) are still passed through. ioredis is an
|
|
263
|
+
* optional package, imported here, the first time a store needs a client: without it, this throws
|
|
264
|
+
* MissingPackageError, saying to install it. A prebuilt client imports nothing.
|
|
265
|
+
*/
|
|
266
|
+
declare function makeRedisClient(config: RedisConfig): Promise<Redis>;
|
|
267
|
+
/**
|
|
268
|
+
* A store's client: one given, or one made at first use (and kept), so ioredis is only imported when it's needed. A
|
|
269
|
+
* client given is there from the start, so the app's shutdown quits it as soon as its store is built.
|
|
259
270
|
*/
|
|
260
|
-
declare
|
|
271
|
+
declare class RedisConnection {
|
|
272
|
+
#private;
|
|
273
|
+
private readonly source;
|
|
274
|
+
constructor(source: Redis | (() => Promise<Redis>));
|
|
275
|
+
client(): Promise<Redis>;
|
|
276
|
+
/** Whether there's a client: one given, or one made for a command. A store that has neither has nothing to close. */
|
|
277
|
+
started(): boolean;
|
|
278
|
+
}
|
|
261
279
|
/** Shared low-level redis primitives, parameterized only by the fully-computed key. No prefixing here on purpose:
|
|
262
280
|
* RedisStore and RedisTaggedStore each compute their own keys and never rely on ioredis's `keyPrefix` client
|
|
263
281
|
* option (which doesn't rewrite SCAN's MATCH pattern, making prefixed flush()/tag-namespace lookups unreliable). */
|
|
264
282
|
declare abstract class RedisPrimitives {
|
|
265
|
-
protected readonly
|
|
266
|
-
protected constructor(redis: Redis);
|
|
283
|
+
protected readonly connection: RedisConnection;
|
|
284
|
+
protected constructor(redis: Redis | RedisConnection | (() => Promise<Redis>));
|
|
285
|
+
/** The client, made at the first command. */
|
|
286
|
+
protected redis(): Promise<Redis>;
|
|
287
|
+
getConnection(): RedisConnection;
|
|
267
288
|
protected rawGet(key: string): Promise<unknown>;
|
|
268
289
|
protected rawMany(keys: string[]): Promise<Record<string, unknown>>;
|
|
269
290
|
protected rawPut(key: string, value: unknown, ms?: number): Promise<boolean>;
|
|
@@ -273,7 +294,7 @@ declare abstract class RedisPrimitives {
|
|
|
273
294
|
}
|
|
274
295
|
declare class RedisStore extends RedisPrimitives implements Store {
|
|
275
296
|
private readonly keyPrefix;
|
|
276
|
-
constructor(redis: Redis, keyPrefix?: string);
|
|
297
|
+
constructor(redis: Redis | RedisConnection | (() => Promise<Redis>), keyPrefix?: string);
|
|
277
298
|
private k;
|
|
278
299
|
getPrefix(): string;
|
|
279
300
|
get(key: string): Promise<unknown>;
|
|
@@ -295,7 +316,7 @@ declare class RedisStore extends RedisPrimitives implements Store {
|
|
|
295
316
|
declare class RedisTaggedStore extends RedisPrimitives implements Store {
|
|
296
317
|
private readonly keyPrefix;
|
|
297
318
|
private readonly tagNames;
|
|
298
|
-
constructor(redis: Redis, keyPrefix: string, tagNames: string[]);
|
|
319
|
+
constructor(redis: Redis | RedisConnection | (() => Promise<Redis>), keyPrefix: string, tagNames: string[]);
|
|
299
320
|
private tagVersion;
|
|
300
321
|
private namespace;
|
|
301
322
|
private k;
|
|
@@ -312,12 +333,13 @@ declare class RedisTaggedStore extends RedisPrimitives implements Store {
|
|
|
312
333
|
|
|
313
334
|
/** SET key value [PX ms] NX to acquire; a Lua script to release only if we still own it (compare-and-delete). */
|
|
314
335
|
declare class RedisLock implements Lock {
|
|
315
|
-
private readonly redis;
|
|
316
336
|
private readonly name;
|
|
317
337
|
private readonly seconds;
|
|
318
338
|
private readonly pollMs;
|
|
319
339
|
private readonly ownerValue;
|
|
320
|
-
|
|
340
|
+
private readonly connection;
|
|
341
|
+
/** `redis` is a client, or a store's connection (whose client is made at first use). */
|
|
342
|
+
constructor(redis: Redis | RedisConnection, name: string, seconds: number | undefined, owner?: string, pollMs?: number);
|
|
321
343
|
owner(): string;
|
|
322
344
|
get<T = boolean>(callback?: () => T | Promise<T>): Promise<T | false>;
|
|
323
345
|
block<T = boolean>(seconds: number, callback?: () => T | Promise<T>): Promise<T | true>;
|
|
@@ -329,13 +351,13 @@ declare class RedisLock implements Lock {
|
|
|
329
351
|
/** The only Repository subclass: the only store where tags() doesn't throw. */
|
|
330
352
|
declare class RedisRepository extends Repository {
|
|
331
353
|
private readonly redisStore;
|
|
332
|
-
|
|
333
|
-
constructor(redisStore: RedisStore, redis: Redis);
|
|
354
|
+
constructor(redisStore: RedisStore);
|
|
334
355
|
/**
|
|
335
356
|
* Closes the redis client (CacheManager.disconnectAll() at shutdown): a connected one with QUIT, one that never
|
|
336
357
|
* connected or is reconnecting without waiting; one already closed is left alone. A client two stores share is quit
|
|
337
358
|
* once: QUIT resolves on the server's reply, but the client reads 'ready' until its socket closes, so the second
|
|
338
359
|
* store waits on the first one's QUIT instead of sending another (which would fail with "Connection is closed.").
|
|
360
|
+
* A store that never made its client has nothing to close.
|
|
339
361
|
*/
|
|
340
362
|
disconnect(): Promise<void>;
|
|
341
363
|
tags(names: string | string[]): CacheRepository;
|
|
@@ -395,6 +417,11 @@ declare class CacheRateLimiter implements RateLimiter$1 {
|
|
|
395
417
|
#private;
|
|
396
418
|
private readonly store;
|
|
397
419
|
constructor(store: () => CacheRepository);
|
|
420
|
+
/** Laravel's RateLimiter::for(): names a limiter that `throttle:<name>` uses. */
|
|
421
|
+
for(name: string, callback: RateLimiterCallback): void;
|
|
422
|
+
limiter(name: string): RateLimiterCallback | undefined;
|
|
423
|
+
/** Laravel's attempt(): false when `key` is out of attempts; else the callback's result (true for nothing), and a hit. */
|
|
424
|
+
attempt<T>(key: string, maxAttempts: number, callback: () => T | Promise<T>, decaySeconds?: number): Promise<T | boolean>;
|
|
398
425
|
tooManyAttempts(key: string, maxAttempts: number): Promise<boolean>;
|
|
399
426
|
hit(key: string, decaySeconds?: number): Promise<number>;
|
|
400
427
|
attempts(key: string): Promise<number>;
|
|
@@ -405,6 +432,29 @@ declare class CacheRateLimiter implements RateLimiter$1 {
|
|
|
405
432
|
protected cleanKey(key: string): string;
|
|
406
433
|
}
|
|
407
434
|
|
|
435
|
+
/**
|
|
436
|
+
* Laravel's Limit, what a named rate limiter returns: `maxAttempts` hits per `decaySeconds`, counted per `by()` key
|
|
437
|
+
* (one count for everyone without it).
|
|
438
|
+
*
|
|
439
|
+
* RateLimiter.for('uploads', (request) => Limit.perMinute(10).by(request.ip() ?? ''))
|
|
440
|
+
*/
|
|
441
|
+
declare class Limit implements RateLimit {
|
|
442
|
+
readonly maxAttempts: number;
|
|
443
|
+
readonly decaySeconds: number;
|
|
444
|
+
readonly unlimited: boolean;
|
|
445
|
+
key: string;
|
|
446
|
+
constructor(maxAttempts: number, decaySeconds: number, unlimited?: boolean);
|
|
447
|
+
static perSecond(maxAttempts: number, decaySeconds?: number): Limit;
|
|
448
|
+
static perMinute(maxAttempts: number, decayMinutes?: number): Limit;
|
|
449
|
+
static perMinutes(decayMinutes: number, maxAttempts: number): Limit;
|
|
450
|
+
static perHour(maxAttempts: number, decayHours?: number): Limit;
|
|
451
|
+
static perDay(maxAttempts: number, decayDays?: number): Limit;
|
|
452
|
+
/** Laravel's Limit::none(): no limit, and no rate limit headers. */
|
|
453
|
+
static none(): Limit;
|
|
454
|
+
/** The key the hits are counted under, such as the user's id or the IP address. */
|
|
455
|
+
by(key: unknown): this;
|
|
456
|
+
}
|
|
457
|
+
|
|
408
458
|
declare const Cache: _orieljs_support.Facade<CacheManager$1, object>;
|
|
409
459
|
/** The RateLimiter facade: RateLimiter.tooManyAttempts(key, 5), RateLimiter.hit(key), RateLimiter.clear(key). */
|
|
410
460
|
declare const RateLimiter: _orieljs_support.Facade<RateLimiter$1, object>;
|
|
@@ -414,6 +464,10 @@ declare function cache(values: Record<string, unknown>, ttlSeconds?: number): Pr
|
|
|
414
464
|
|
|
415
465
|
declare class CacheServiceProvider extends ServiceProvider {
|
|
416
466
|
register(): void;
|
|
467
|
+
boot(): void;
|
|
417
468
|
}
|
|
418
469
|
|
|
419
|
-
|
|
470
|
+
/** Laravel's `cache:clear` and `cache:forget`, on the default store or the one named. */
|
|
471
|
+
declare function registerCacheCommands(kernel: ConsoleKernel, app: Application): void;
|
|
472
|
+
|
|
473
|
+
export { CACHE_TABLE_MIGRATION, Cache, CacheManager, CacheRateLimiter, CacheServiceProvider, DatabaseLock, DatabaseStore, FileStore, GenericLock, InvalidCacheConfigError, Limit, type LockFactory, LockTimeoutError, MemoryStore, RateLimiter, RedisConnection, RedisLock, RedisRepository, RedisStore, RedisTaggedStore, Repository, type Store, TagsNotSupportedError, UnknownCacheDriverError, UnknownCacheStoreError, cache, defaultLockFactory, deserialize, makeRedisClient, registerCacheCommands, resolveRedisConfig, roundTrip, serialize };
|
package/dist/index.js
CHANGED
|
@@ -545,9 +545,19 @@ var DatabaseStore = class {
|
|
|
545
545
|
const deleted = await this.connection.table(this.table).where("key", this.k(key)).delete();
|
|
546
546
|
return deleted > 0;
|
|
547
547
|
}
|
|
548
|
+
/**
|
|
549
|
+
* Deletes this store's keys: those starting with its prefix (every row without one). The prefix's `%` and `_` are
|
|
550
|
+
* escaped, so another app's keys in the same table, `appXcache_…` beside `app_cache_…`, stay.
|
|
551
|
+
*/
|
|
548
552
|
async flush() {
|
|
549
|
-
if (this.keyPrefix)
|
|
550
|
-
|
|
553
|
+
if (!this.keyPrefix) {
|
|
554
|
+
await this.connection.table(this.table).delete();
|
|
555
|
+
return true;
|
|
556
|
+
}
|
|
557
|
+
const column = this.connection.getDriverName() === "mysql" ? "`key`" : '"key"';
|
|
558
|
+
const pattern = `${this.keyPrefix.replace(/[!%_]/g, (character) => `!${character}`)}%`;
|
|
559
|
+
const query = this.connection.table(this.table);
|
|
560
|
+
await query.whereRaw(`${column} like ? escape '!'`, [pattern]).delete();
|
|
551
561
|
return true;
|
|
552
562
|
}
|
|
553
563
|
};
|
|
@@ -647,25 +657,49 @@ export default class extends Migration {
|
|
|
647
657
|
|
|
648
658
|
// stores/RedisStore.ts
|
|
649
659
|
import { createHash as createHash2, randomUUID } from "crypto";
|
|
650
|
-
import
|
|
651
|
-
function makeRedisClient(config) {
|
|
660
|
+
import { importOptional } from "@orieljs/support";
|
|
661
|
+
async function makeRedisClient(config) {
|
|
652
662
|
if (typeof config.client === "object" && config.client !== null) return config.client;
|
|
663
|
+
const { Redis } = await importOptional("ioredis", "The redis cache store", () => import("ioredis"));
|
|
653
664
|
const { client: _client, url, driver: _driver, prefix: _prefix, connection: _connection, ...options } = config;
|
|
654
665
|
if (typeof url === "string") return new Redis(url, options);
|
|
655
666
|
return new Redis(options);
|
|
656
667
|
}
|
|
668
|
+
var RedisConnection = class {
|
|
669
|
+
constructor(source) {
|
|
670
|
+
this.source = source;
|
|
671
|
+
if (typeof source !== "function") this.#client = Promise.resolve(source);
|
|
672
|
+
}
|
|
673
|
+
source;
|
|
674
|
+
#client;
|
|
675
|
+
client() {
|
|
676
|
+
return this.#client ??= this.source();
|
|
677
|
+
}
|
|
678
|
+
/** Whether there's a client: one given, or one made for a command. A store that has neither has nothing to close. */
|
|
679
|
+
started() {
|
|
680
|
+
return this.#client !== void 0;
|
|
681
|
+
}
|
|
682
|
+
};
|
|
683
|
+
var connectionOf = (redis) => redis instanceof RedisConnection ? redis : new RedisConnection(redis);
|
|
657
684
|
var RedisPrimitives = class {
|
|
685
|
+
connection;
|
|
658
686
|
constructor(redis) {
|
|
659
|
-
this.
|
|
687
|
+
this.connection = connectionOf(redis);
|
|
688
|
+
}
|
|
689
|
+
/** The client, made at the first command. */
|
|
690
|
+
redis() {
|
|
691
|
+
return this.connection.client();
|
|
692
|
+
}
|
|
693
|
+
getConnection() {
|
|
694
|
+
return this.connection;
|
|
660
695
|
}
|
|
661
|
-
redis;
|
|
662
696
|
async rawGet(key) {
|
|
663
|
-
const raw = await this.redis.get(key);
|
|
697
|
+
const raw = await (await this.redis()).get(key);
|
|
664
698
|
return raw === null ? void 0 : deserialize(raw);
|
|
665
699
|
}
|
|
666
700
|
async rawMany(keys) {
|
|
667
701
|
if (keys.length === 0) return {};
|
|
668
|
-
const values = await this.redis.mget(...keys);
|
|
702
|
+
const values = await (await this.redis()).mget(...keys);
|
|
669
703
|
const result = {};
|
|
670
704
|
keys.forEach((key, i) => {
|
|
671
705
|
const raw = values[i];
|
|
@@ -674,19 +708,21 @@ var RedisPrimitives = class {
|
|
|
674
708
|
return result;
|
|
675
709
|
}
|
|
676
710
|
async rawPut(key, value, ms) {
|
|
677
|
-
|
|
678
|
-
|
|
711
|
+
const redis = await this.redis();
|
|
712
|
+
if (ms === void 0) await redis.set(key, serialize(roundTrip(value)));
|
|
713
|
+
else await redis.set(key, serialize(roundTrip(value)), "PX", Math.max(1, Math.round(ms)));
|
|
679
714
|
return true;
|
|
680
715
|
}
|
|
681
716
|
async rawAdd(key, value, ms) {
|
|
682
|
-
const
|
|
717
|
+
const redis = await this.redis();
|
|
718
|
+
const result = ms === void 0 ? await redis.set(key, serialize(roundTrip(value)), "NX") : await redis.set(key, serialize(roundTrip(value)), "PX", Math.max(1, Math.round(ms)), "NX");
|
|
683
719
|
return result === "OK";
|
|
684
720
|
}
|
|
685
|
-
rawIncrement(key, by) {
|
|
686
|
-
return this.redis.incrby(key, by);
|
|
721
|
+
async rawIncrement(key, by) {
|
|
722
|
+
return (await this.redis()).incrby(key, by);
|
|
687
723
|
}
|
|
688
724
|
async rawForget(key) {
|
|
689
|
-
return await this.redis.del(key) > 0;
|
|
725
|
+
return await (await this.redis()).del(key) > 0;
|
|
690
726
|
}
|
|
691
727
|
};
|
|
692
728
|
var RedisStore = class extends RedisPrimitives {
|
|
@@ -733,16 +769,17 @@ var RedisStore = class extends RedisPrimitives {
|
|
|
733
769
|
return this.rawForget(this.k(key));
|
|
734
770
|
}
|
|
735
771
|
async flush() {
|
|
772
|
+
const redis = await this.redis();
|
|
736
773
|
let cursor = "0";
|
|
737
774
|
do {
|
|
738
|
-
const [next, keys] = await
|
|
775
|
+
const [next, keys] = await redis.scan(cursor, "MATCH", `${this.keyPrefix}*`, "COUNT", 200);
|
|
739
776
|
cursor = next;
|
|
740
|
-
if (keys.length > 0) await
|
|
777
|
+
if (keys.length > 0) await redis.unlink(...keys);
|
|
741
778
|
} while (cursor !== "0");
|
|
742
779
|
return true;
|
|
743
780
|
}
|
|
744
781
|
tags(names) {
|
|
745
|
-
return new RedisTaggedStore(this.
|
|
782
|
+
return new RedisTaggedStore(this.connection, this.keyPrefix, names);
|
|
746
783
|
}
|
|
747
784
|
};
|
|
748
785
|
var RedisTaggedStore = class extends RedisPrimitives {
|
|
@@ -755,11 +792,12 @@ var RedisTaggedStore = class extends RedisPrimitives {
|
|
|
755
792
|
tagNames;
|
|
756
793
|
async tagVersion(name) {
|
|
757
794
|
const key = `${this.keyPrefix}tag:${name}:version`;
|
|
758
|
-
const
|
|
795
|
+
const redis = await this.redis();
|
|
796
|
+
const existing = await redis.get(key);
|
|
759
797
|
if (existing !== null) return existing;
|
|
760
798
|
const version = randomUUID();
|
|
761
|
-
const set = await
|
|
762
|
-
return set === "OK" ? version : await
|
|
799
|
+
const set = await redis.set(key, version, "NX");
|
|
800
|
+
return set === "OK" ? version : await redis.get(key) ?? version;
|
|
763
801
|
}
|
|
764
802
|
async namespace() {
|
|
765
803
|
const versions = await Promise.all(this.tagNames.map((name) => this.tagVersion(name)));
|
|
@@ -801,7 +839,8 @@ var RedisTaggedStore = class extends RedisPrimitives {
|
|
|
801
839
|
return this.rawForget(await this.k(key));
|
|
802
840
|
}
|
|
803
841
|
async flush() {
|
|
804
|
-
|
|
842
|
+
const redis = await this.redis();
|
|
843
|
+
await Promise.all(this.tagNames.map((name) => redis.set(`${this.keyPrefix}tag:${name}:version`, randomUUID())));
|
|
805
844
|
return true;
|
|
806
845
|
}
|
|
807
846
|
};
|
|
@@ -811,18 +850,19 @@ import { setTimeout as sleep3 } from "timers/promises";
|
|
|
811
850
|
import { Str as Str3 } from "@orieljs/support";
|
|
812
851
|
var RELEASE_SCRIPT = 'if redis.call("get", KEYS[1]) == ARGV[1] then return redis.call("del", KEYS[1]) else return 0 end';
|
|
813
852
|
var RedisLock = class {
|
|
853
|
+
/** `redis` is a client, or a store's connection (whose client is made at first use). */
|
|
814
854
|
constructor(redis, name, seconds, owner, pollMs = 50) {
|
|
815
|
-
this.redis = redis;
|
|
816
855
|
this.name = name;
|
|
817
856
|
this.seconds = seconds;
|
|
818
857
|
this.pollMs = pollMs;
|
|
819
858
|
this.ownerValue = owner ?? Str3.random(20);
|
|
859
|
+
this.connection = redis instanceof RedisConnection ? redis : new RedisConnection(redis);
|
|
820
860
|
}
|
|
821
|
-
redis;
|
|
822
861
|
name;
|
|
823
862
|
seconds;
|
|
824
863
|
pollMs;
|
|
825
864
|
ownerValue;
|
|
865
|
+
connection;
|
|
826
866
|
owner() {
|
|
827
867
|
return this.ownerValue;
|
|
828
868
|
}
|
|
@@ -851,14 +891,15 @@ var RedisLock = class {
|
|
|
851
891
|
}
|
|
852
892
|
}
|
|
853
893
|
async release() {
|
|
854
|
-
const result = await this.
|
|
894
|
+
const result = await (await this.connection.client()).eval(RELEASE_SCRIPT, 1, this.name, this.ownerValue);
|
|
855
895
|
return result === 1;
|
|
856
896
|
}
|
|
857
897
|
async forceRelease() {
|
|
858
|
-
await this.
|
|
898
|
+
await (await this.connection.client()).del(this.name);
|
|
859
899
|
}
|
|
860
900
|
async acquire() {
|
|
861
|
-
const
|
|
901
|
+
const redis = await this.connection.client();
|
|
902
|
+
const result = this.seconds === void 0 ? await redis.set(this.name, this.ownerValue, "NX") : await redis.set(this.name, this.ownerValue, "PX", Math.max(1, Math.round(this.seconds * 1e3)), "NX");
|
|
862
903
|
return result === "OK";
|
|
863
904
|
}
|
|
864
905
|
};
|
|
@@ -866,21 +907,23 @@ var RedisLock = class {
|
|
|
866
907
|
// stores/RedisRepository.ts
|
|
867
908
|
var quitting = /* @__PURE__ */ new WeakMap();
|
|
868
909
|
var RedisRepository = class extends Repository {
|
|
869
|
-
constructor(redisStore
|
|
870
|
-
super(redisStore, (_store, name, seconds, owner) => new RedisLock(
|
|
910
|
+
constructor(redisStore) {
|
|
911
|
+
super(redisStore, (_store, name, seconds, owner) => new RedisLock(redisStore.getConnection(), redisStore.getPrefix() + name, seconds, owner));
|
|
871
912
|
this.redisStore = redisStore;
|
|
872
|
-
this.redis = redis;
|
|
873
913
|
}
|
|
874
914
|
redisStore;
|
|
875
|
-
redis;
|
|
876
915
|
/**
|
|
877
916
|
* Closes the redis client (CacheManager.disconnectAll() at shutdown): a connected one with QUIT, one that never
|
|
878
917
|
* connected or is reconnecting without waiting; one already closed is left alone. A client two stores share is quit
|
|
879
918
|
* once: QUIT resolves on the server's reply, but the client reads 'ready' until its socket closes, so the second
|
|
880
919
|
* store waits on the first one's QUIT instead of sending another (which would fail with "Connection is closed.").
|
|
920
|
+
* A store that never made its client has nothing to close.
|
|
881
921
|
*/
|
|
882
922
|
async disconnect() {
|
|
883
|
-
const
|
|
923
|
+
const connection = this.redisStore.getConnection();
|
|
924
|
+
if (!connection.started()) return;
|
|
925
|
+
const redis = await connection.client().catch(() => void 0);
|
|
926
|
+
if (redis === void 0) return;
|
|
884
927
|
const pending = quitting.get(redis);
|
|
885
928
|
if (pending) return pending;
|
|
886
929
|
if (redis.status === "end") return;
|
|
@@ -894,7 +937,7 @@ var RedisRepository = class extends Repository {
|
|
|
894
937
|
const list = Array.isArray(names) ? names : [names];
|
|
895
938
|
const taggedStore = this.redisStore.tags(list);
|
|
896
939
|
const prefix = this.redisStore.getPrefix();
|
|
897
|
-
return new Repository(taggedStore, (_store, name, seconds, owner) => new RedisLock(this.
|
|
940
|
+
return new Repository(taggedStore, (_store, name, seconds, owner) => new RedisLock(this.redisStore.getConnection(), prefix + name, seconds, owner));
|
|
898
941
|
}
|
|
899
942
|
};
|
|
900
943
|
|
|
@@ -937,22 +980,22 @@ var CacheManager = class {
|
|
|
937
980
|
cfg,
|
|
938
981
|
(connectionName) => this.container.make(ConfigRepository).get(`database.redis.${connectionName}`, {})
|
|
939
982
|
);
|
|
940
|
-
const
|
|
941
|
-
const store = new RedisStore(
|
|
942
|
-
return new RedisRepository(store
|
|
983
|
+
const client = typeof resolved.client === "object" && resolved.client !== null ? resolved.client : void 0;
|
|
984
|
+
const store = new RedisStore(client ?? (() => makeRedisClient(resolved)), this.str(cfg.prefix));
|
|
985
|
+
return new RedisRepository(store);
|
|
943
986
|
}
|
|
944
987
|
store(name) {
|
|
945
988
|
const cacheConfig = this.cacheConfig();
|
|
946
|
-
const
|
|
947
|
-
let repository = this.stores.get(
|
|
989
|
+
const storeName2 = name ?? cacheConfig.default;
|
|
990
|
+
let repository = this.stores.get(storeName2);
|
|
948
991
|
if (!repository) {
|
|
949
|
-
const storeConfig = cacheConfig.stores[
|
|
950
|
-
if (!storeConfig) throw new UnknownCacheStoreError(
|
|
992
|
+
const storeConfig = cacheConfig.stores[storeName2];
|
|
993
|
+
if (!storeConfig) throw new UnknownCacheStoreError(storeName2);
|
|
951
994
|
const driverName = storeConfig.driver;
|
|
952
995
|
const driver = driverName ? this.drivers.get(driverName) : void 0;
|
|
953
996
|
if (!driver) throw new UnknownCacheDriverError(String(driverName));
|
|
954
997
|
repository = driver({ ...storeConfig, prefix: storeConfig.prefix ?? cacheConfig.prefix ?? "" });
|
|
955
|
-
this.stores.set(
|
|
998
|
+
this.stores.set(storeName2, repository);
|
|
956
999
|
}
|
|
957
1000
|
return repository;
|
|
958
1001
|
}
|
|
@@ -1031,6 +1074,21 @@ var CacheRateLimiter = class {
|
|
|
1031
1074
|
this.store = store;
|
|
1032
1075
|
}
|
|
1033
1076
|
store;
|
|
1077
|
+
#limiters = /* @__PURE__ */ new Map();
|
|
1078
|
+
/** Laravel's RateLimiter::for(): names a limiter that `throttle:<name>` uses. */
|
|
1079
|
+
for(name, callback) {
|
|
1080
|
+
this.#limiters.set(name, callback);
|
|
1081
|
+
}
|
|
1082
|
+
limiter(name) {
|
|
1083
|
+
return this.#limiters.get(name);
|
|
1084
|
+
}
|
|
1085
|
+
/** Laravel's attempt(): false when `key` is out of attempts; else the callback's result (true for nothing), and a hit. */
|
|
1086
|
+
async attempt(key, maxAttempts, callback, decaySeconds = 60) {
|
|
1087
|
+
if (await this.tooManyAttempts(key, maxAttempts)) return false;
|
|
1088
|
+
const result = await callback();
|
|
1089
|
+
await this.hit(key, decaySeconds);
|
|
1090
|
+
return result === void 0 || result === null ? true : result;
|
|
1091
|
+
}
|
|
1034
1092
|
async tooManyAttempts(key, maxAttempts) {
|
|
1035
1093
|
const clean = this.cleanKey(key);
|
|
1036
1094
|
if (await this.#attempts(clean) >= maxAttempts) {
|
|
@@ -1072,6 +1130,43 @@ var CacheRateLimiter = class {
|
|
|
1072
1130
|
}
|
|
1073
1131
|
};
|
|
1074
1132
|
|
|
1133
|
+
// RateLimiting/Limit.ts
|
|
1134
|
+
var Limit = class _Limit {
|
|
1135
|
+
constructor(maxAttempts, decaySeconds, unlimited = false) {
|
|
1136
|
+
this.maxAttempts = maxAttempts;
|
|
1137
|
+
this.decaySeconds = decaySeconds;
|
|
1138
|
+
this.unlimited = unlimited;
|
|
1139
|
+
}
|
|
1140
|
+
maxAttempts;
|
|
1141
|
+
decaySeconds;
|
|
1142
|
+
unlimited;
|
|
1143
|
+
key = "";
|
|
1144
|
+
static perSecond(maxAttempts, decaySeconds = 1) {
|
|
1145
|
+
return new _Limit(maxAttempts, decaySeconds);
|
|
1146
|
+
}
|
|
1147
|
+
static perMinute(maxAttempts, decayMinutes = 1) {
|
|
1148
|
+
return new _Limit(maxAttempts, 60 * decayMinutes);
|
|
1149
|
+
}
|
|
1150
|
+
static perMinutes(decayMinutes, maxAttempts) {
|
|
1151
|
+
return new _Limit(maxAttempts, 60 * decayMinutes);
|
|
1152
|
+
}
|
|
1153
|
+
static perHour(maxAttempts, decayHours = 1) {
|
|
1154
|
+
return new _Limit(maxAttempts, 3600 * decayHours);
|
|
1155
|
+
}
|
|
1156
|
+
static perDay(maxAttempts, decayDays = 1) {
|
|
1157
|
+
return new _Limit(maxAttempts, 86400 * decayDays);
|
|
1158
|
+
}
|
|
1159
|
+
/** Laravel's Limit::none(): no limit, and no rate limit headers. */
|
|
1160
|
+
static none() {
|
|
1161
|
+
return new _Limit(Number.MAX_SAFE_INTEGER, 60, true);
|
|
1162
|
+
}
|
|
1163
|
+
/** The key the hits are counted under, such as the user's id or the IP address. */
|
|
1164
|
+
by(key) {
|
|
1165
|
+
this.key = String(key);
|
|
1166
|
+
return this;
|
|
1167
|
+
}
|
|
1168
|
+
};
|
|
1169
|
+
|
|
1075
1170
|
// facade.ts
|
|
1076
1171
|
import { CacheManager as CacheManagerToken2, RateLimiter as RateLimiterToken } from "@orieljs/contracts";
|
|
1077
1172
|
import { inject } from "@orieljs/container";
|
|
@@ -1088,8 +1183,48 @@ function cache(arg, ttlSeconds) {
|
|
|
1088
1183
|
}
|
|
1089
1184
|
|
|
1090
1185
|
// CacheServiceProvider.ts
|
|
1091
|
-
import { CacheManager as CacheManagerToken3, ConfigRepository as ConfigRepository2, RateLimiter as RateLimiter2 } from "@orieljs/contracts";
|
|
1186
|
+
import { CacheManager as CacheManagerToken3, ConfigRepository as ConfigRepository2, ConsoleKernel, RateLimiter as RateLimiter2 } from "@orieljs/contracts";
|
|
1092
1187
|
import { ServiceProvider } from "@orieljs/support";
|
|
1188
|
+
|
|
1189
|
+
// commands.ts
|
|
1190
|
+
import { CacheManager as CacheManager2 } from "@orieljs/contracts";
|
|
1191
|
+
var storeName = (command) => {
|
|
1192
|
+
const given = command.argument("store");
|
|
1193
|
+
return typeof given === "string" && given !== "" ? given : void 0;
|
|
1194
|
+
};
|
|
1195
|
+
function registerCacheCommands(kernel, app) {
|
|
1196
|
+
kernel.command("cache:clear {store? : The name of the store you would like to clear}", async function() {
|
|
1197
|
+
let flushed;
|
|
1198
|
+
try {
|
|
1199
|
+
flushed = await app.make(CacheManager2).store(storeName(this)).flush();
|
|
1200
|
+
} catch (error) {
|
|
1201
|
+
this.error(error instanceof Error ? error.message : String(error));
|
|
1202
|
+
return 1;
|
|
1203
|
+
}
|
|
1204
|
+
if (!flushed) {
|
|
1205
|
+
this.error("Failed to clear cache. Make sure you have the appropriate permissions.");
|
|
1206
|
+
return 1;
|
|
1207
|
+
}
|
|
1208
|
+
this.info("Application cache cleared successfully.");
|
|
1209
|
+
return 0;
|
|
1210
|
+
}).purpose("Flush the application cache");
|
|
1211
|
+
kernel.command(
|
|
1212
|
+
"cache:forget {key : The key to remove} {store? : The store to remove the key from}",
|
|
1213
|
+
async function() {
|
|
1214
|
+
const key = String(this.argument("key"));
|
|
1215
|
+
try {
|
|
1216
|
+
await app.make(CacheManager2).store(storeName(this)).forget(key);
|
|
1217
|
+
} catch (error) {
|
|
1218
|
+
this.error(error instanceof Error ? error.message : String(error));
|
|
1219
|
+
return 1;
|
|
1220
|
+
}
|
|
1221
|
+
this.info(`The [${key}] key has been removed from the cache.`);
|
|
1222
|
+
return 0;
|
|
1223
|
+
}
|
|
1224
|
+
).purpose("Remove an item from the cache");
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
// CacheServiceProvider.ts
|
|
1093
1228
|
var CacheServiceProvider = class extends ServiceProvider {
|
|
1094
1229
|
register() {
|
|
1095
1230
|
this.mergeConfigFrom(
|
|
@@ -1120,6 +1255,9 @@ var CacheServiceProvider = class extends ServiceProvider {
|
|
|
1120
1255
|
});
|
|
1121
1256
|
});
|
|
1122
1257
|
}
|
|
1258
|
+
boot() {
|
|
1259
|
+
if (this.app.bound(ConsoleKernel)) registerCacheCommands(this.app.make(ConsoleKernel), this.app);
|
|
1260
|
+
}
|
|
1123
1261
|
};
|
|
1124
1262
|
export {
|
|
1125
1263
|
CACHE_TABLE_MIGRATION,
|
|
@@ -1132,9 +1270,11 @@ export {
|
|
|
1132
1270
|
FileStore,
|
|
1133
1271
|
GenericLock,
|
|
1134
1272
|
InvalidCacheConfigError,
|
|
1273
|
+
Limit,
|
|
1135
1274
|
LockTimeoutError,
|
|
1136
1275
|
MemoryStore,
|
|
1137
1276
|
RateLimiter,
|
|
1277
|
+
RedisConnection,
|
|
1138
1278
|
RedisLock,
|
|
1139
1279
|
RedisRepository,
|
|
1140
1280
|
RedisStore,
|
|
@@ -1147,6 +1287,7 @@ export {
|
|
|
1147
1287
|
defaultLockFactory,
|
|
1148
1288
|
deserialize,
|
|
1149
1289
|
makeRedisClient,
|
|
1290
|
+
registerCacheCommands,
|
|
1150
1291
|
resolveRedisConfig,
|
|
1151
1292
|
roundTrip,
|
|
1152
1293
|
serialize
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../errors.ts","../serialize.ts","../locks/GenericLock.ts","../Repository.ts","../stores/MemoryStore.ts","../stores/FileStore.ts","../insertOrTakeOver.ts","../stores/DatabaseStore.ts","../locks/DatabaseLock.ts","../migrations.ts","../stores/RedisStore.ts","../locks/RedisLock.ts","../stores/RedisRepository.ts","../CacheManager.ts","../RateLimiter.ts","../facade.ts","../CacheServiceProvider.ts"],"sourcesContent":["import type { OrielError } from '@orieljs/contracts'\n\nexport class LockTimeoutError extends Error implements OrielError {\n readonly kind = 'Server' as const\n readonly status = 500\n override readonly name = 'LockTimeoutError'\n constructor(readonly lockName: string) {\n super(`Unable to acquire lock [${lockName}].`)\n }\n}\n\nexport class TagsNotSupportedError extends Error implements OrielError {\n readonly kind = 'Server' as const\n readonly status = 500\n override readonly name = 'TagsNotSupportedError'\n constructor(store: string) {\n super(`The [${store}] cache store does not support tags. Only the redis store does.`)\n }\n}\n\nexport class UnknownCacheStoreError extends Error implements OrielError {\n readonly kind = 'Server' as const\n readonly status = 500\n override readonly name = 'UnknownCacheStoreError'\n constructor(name: string) {\n super(`Cache store [${name}] is not configured. Add it to config('cache.stores').`)\n }\n}\n\nexport class UnknownCacheDriverError extends Error implements OrielError {\n readonly kind = 'Server' as const\n readonly status = 500\n override readonly name = 'UnknownCacheDriverError'\n constructor(driver: string) {\n super(`Cache driver [${driver}] is not supported. Register it first with CacheManager.extend().`)\n }\n}\n\nexport class InvalidCacheConfigError extends Error implements OrielError {\n readonly kind = 'Server' as const\n readonly status = 500\n override readonly name = 'InvalidCacheConfigError'\n}\n","/**\n * Cache values always round-trip through JSON.stringify/JSON.parse, on every store — even the in-process\n * memory store — so switching `cache.default` never changes behaviour. Practical limits this implies:\n * - A Date becomes a string (ISO 8601). Read it back with `new Date(...)`, or use a Model cast.\n * - undefined properties on an object are dropped, and a bare `undefined` value is stored as `null` (it reads\n * back as `null`, not as a miss: `undefined` is only ever the \"cache miss\" result of a read).\n * - NaN and Infinity become `null`.\n * - Map, Set, class instances, functions and symbols do not round-trip: plain data only.\n */\nexport function serialize(value: unknown): string {\n return JSON.stringify(value) ?? 'null'\n}\n\nexport function deserialize(raw: string): unknown {\n return JSON.parse(raw)\n}\n\n/** Deep-clones `value` through JSON, applying the same limits as every persisted store. */\nexport function roundTrip<T>(value: T): T {\n return JSON.parse(serialize(value)) as T\n}\n","import { setTimeout as sleep } from 'node:timers/promises'\nimport type { Lock } from '@orieljs/contracts'\nimport { Str } from '@orieljs/support'\nimport { LockTimeoutError } from '../errors'\nimport type { Store } from '../Store'\n\n/**\n * Backs a Lock with any Store whose add() is atomic (memory, array, file). Shares the store's key space with\n * regular cache entries, exactly like Laravel's CacheLock: `Cache::lock('x')` and `Cache::put('x', ...)` name the\n * same slot on purpose.\n */\nexport class GenericLock implements Lock {\n private readonly ownerValue: string\n\n constructor(\n private readonly store: Store,\n private readonly name: string,\n private readonly seconds: number | undefined,\n owner?: string,\n private readonly pollMs = 50,\n ) {\n this.ownerValue = owner ?? Str.random(20)\n }\n\n owner(): string {\n return this.ownerValue\n }\n\n async get<T = boolean>(callback?: () => T | Promise<T>): Promise<T | false> {\n const acquired = await this.store.add(this.name, this.ownerValue, this.seconds)\n if (!acquired) return false\n if (!callback) return true as T\n try {\n return await callback()\n } finally {\n await this.release()\n }\n }\n\n async block<T = boolean>(seconds: number, callback?: () => T | Promise<T>): Promise<T | true> {\n const deadline = Date.now() + seconds * 1000\n for (;;) {\n if (await this.get()) break\n if (Date.now() >= deadline) throw new LockTimeoutError(this.name)\n await sleep(this.pollMs)\n }\n if (!callback) return true\n try {\n return await callback()\n } finally {\n await this.release()\n }\n }\n\n async release(): Promise<boolean> {\n const current = await this.store.get(this.name)\n if (current !== this.ownerValue) return false\n return this.store.forget(this.name)\n }\n\n async forceRelease(): Promise<void> {\n await this.store.forget(this.name)\n }\n}\n","import type { CacheRepository, Lock } from '@orieljs/contracts'\nimport { GenericLock } from './locks/GenericLock'\nimport { TagsNotSupportedError } from './errors'\nimport type { Store } from './Store'\n\nexport type LockFactory = (store: Store, name: string, seconds: number | undefined, owner: string | undefined) => Lock\n\nexport const defaultLockFactory: LockFactory = (store, name, seconds, owner) => new GenericLock(store, name, seconds, owner)\n\n/** Implements the full CacheRepository API over any Store, the way Illuminate\\Cache\\Repository wraps a Store. */\nexport class Repository implements CacheRepository {\n constructor(\n protected readonly store: Store,\n private readonly lockFactory: LockFactory = defaultLockFactory,\n ) {}\n\n async get<T = unknown>(key: string, defaultValue?: T | (() => T)): Promise<T | undefined> {\n const value = await this.store.get(key)\n if (value !== undefined) return value as T\n return typeof defaultValue === 'function' ? (defaultValue as () => T)() : defaultValue\n }\n\n async many<T = unknown>(keys: string[]): Promise<Record<string, T | undefined>> {\n const found = await this.store.many(keys)\n const result: Record<string, T | undefined> = {}\n for (const key of keys) result[key] = found[key] as T | undefined\n return result\n }\n\n async has(key: string): Promise<boolean> {\n return (await this.store.get(key)) !== undefined\n }\n\n async missing(key: string): Promise<boolean> {\n return !(await this.has(key))\n }\n\n async put(key: string, value: unknown, ttlSeconds?: number): Promise<boolean> {\n if (ttlSeconds !== undefined && ttlSeconds <= 0) {\n await this.store.forget(key)\n return true\n }\n if (ttlSeconds === undefined) return this.store.putForever(key, value)\n return this.store.put(key, value, ttlSeconds)\n }\n\n async add(key: string, value: unknown, ttlSeconds?: number): Promise<boolean> {\n if (ttlSeconds !== undefined && ttlSeconds <= 0) return false\n return this.store.add(key, value, ttlSeconds)\n }\n\n increment(key: string, by = 1): Promise<number> {\n return this.store.increment(key, by)\n }\n\n decrement(key: string, by = 1): Promise<number> {\n return this.store.decrement(key, by)\n }\n\n forever(key: string, value: unknown): Promise<boolean> {\n return this.store.putForever(key, value)\n }\n\n async pull<T = unknown>(key: string, defaultValue?: T): Promise<T | undefined> {\n const value = await this.get<T>(key)\n await this.forget(key)\n return value === undefined ? defaultValue : value\n }\n\n forget(key: string): Promise<boolean> {\n return this.store.forget(key)\n }\n\n flush(): Promise<boolean> {\n return this.store.flush()\n }\n\n async remember<T>(key: string, ttlSeconds: number, callback: () => T | Promise<T>): Promise<T> {\n const cached = await this.get<T>(key)\n if (cached !== undefined) return cached\n const value = await callback()\n if (value !== undefined) await this.put(key, value, ttlSeconds)\n return value\n }\n\n async rememberForever<T>(key: string, callback: () => T | Promise<T>): Promise<T> {\n const cached = await this.get<T>(key)\n if (cached !== undefined) return cached\n const value = await callback()\n if (value !== undefined) await this.forever(key, value)\n return value\n }\n\n lock(name: string, seconds?: number, owner?: string): Lock {\n // Laravel's semantics: 0 (and anything <= 0) seconds means \"no expiry\", exactly like `undefined`. Locks are\n // always positive-duration in practice, but callers that compute `uniqueFor ?? 0` (Bus's UniqueLock, for\n // example) need `lock(key, 0)` to behave the same as `lock(key)`, not to expire immediately.\n const normalizedSeconds = seconds !== undefined && seconds <= 0 ? undefined : seconds\n return this.lockFactory(this.store, name, normalizedSeconds, owner)\n }\n\n tags(_names: string | string[]): CacheRepository {\n throw new TagsNotSupportedError(this.store.constructor.name)\n }\n}\n","import { InvalidCacheConfigError } from '../errors'\nimport { roundTrip } from '../serialize'\nimport type { Store } from '../Store'\n\ninterface Entry {\n value: unknown\n expiresAt: number | undefined\n}\n\n/**\n * Backs both the `memory` and `array` drivers: `array` is just a MemoryStore with no `maxItems` bound.\n * A bounded store evicts least-recently-used entries, and that includes held locks (GenericLock keys).\n */\nexport class MemoryStore implements Store {\n private readonly entries = new Map<string, Entry>()\n\n constructor(\n private readonly keyPrefix: string = '',\n private readonly maxItems?: number,\n ) {\n if (maxItems !== undefined && !(maxItems >= 1)) {\n throw new InvalidCacheConfigError(`Memory cache maxItems must be at least 1, got [${maxItems}].`)\n }\n }\n\n private k(key: string): string {\n return this.keyPrefix + key\n }\n\n /** Reads and, on a hit, re-inserts the entry so Map iteration order tracks recency (a simple LRU). */\n private read(key: string): Entry | undefined {\n const entry = this.entries.get(key)\n if (!entry) return undefined\n if (entry.expiresAt !== undefined && entry.expiresAt <= Date.now()) {\n this.entries.delete(key)\n return undefined\n }\n this.entries.delete(key)\n this.entries.set(key, entry)\n return entry\n }\n\n private write(key: string, value: unknown, expiresAt: number | undefined): void {\n this.entries.delete(key)\n this.entries.set(key, { value: roundTrip(value), expiresAt })\n if (this.maxItems !== undefined) {\n while (this.entries.size > this.maxItems) {\n const oldest = this.entries.keys().next().value\n if (oldest === undefined) break\n this.entries.delete(oldest)\n }\n }\n }\n\n async get(key: string): Promise<unknown> {\n return this.read(this.k(key))?.value\n }\n\n async many(keys: string[]): Promise<Record<string, unknown>> {\n const result: Record<string, unknown> = {}\n for (const key of keys) {\n const entry = this.read(this.k(key))\n if (entry) result[key] = entry.value\n }\n return result\n }\n\n async put(key: string, value: unknown, seconds: number): Promise<boolean> {\n this.write(this.k(key), value, Date.now() + seconds * 1000)\n return true\n }\n\n async putForever(key: string, value: unknown): Promise<boolean> {\n this.write(this.k(key), value, undefined)\n return true\n }\n\n async add(key: string, value: unknown, seconds?: number): Promise<boolean> {\n const k = this.k(key)\n if (this.read(k) !== undefined) return false\n this.write(k, value, seconds === undefined ? undefined : Date.now() + seconds * 1000)\n return true\n }\n\n async increment(key: string, by: number): Promise<number> {\n const k = this.k(key)\n const existing = this.read(k)\n const current = typeof existing?.value === 'number' ? existing.value : 0\n const next = current + by\n this.write(k, next, existing?.expiresAt)\n return next\n }\n\n async decrement(key: string, by: number): Promise<number> {\n return this.increment(key, -by)\n }\n\n async forget(key: string): Promise<boolean> {\n return this.entries.delete(this.k(key))\n }\n\n async flush(): Promise<boolean> {\n this.entries.clear()\n return true\n }\n}\n","import { createHash } from 'node:crypto'\nimport { link, mkdir, readFile, rename, rm, stat, writeFile } from 'node:fs/promises'\nimport { dirname, join } from 'node:path'\nimport { deserialize, roundTrip, serialize } from '../serialize'\nimport type { Store } from '../Store'\n\n/**\n * Unix-milliseconds sentinel for \"forever\" (13 digits, year 2286 — the same horizon as Laravel's FileStore\n * sentinel, just in milliseconds instead of seconds). Millisecond, not second, resolution: the test suite (and\n * Console's scheduler, which can pass sub-second-rounding-sensitive TTLs) relies on short TTLs like 0.05s\n * actually expiring within tens of milliseconds, which a whole-seconds timestamp can't represent.\n */\nconst FOREVER = 9999999999999\n\n/**\n * How old a key's takeover mutex file must be before another process may assume its holder crashed. The\n * critical section it guards is one small read plus a rename, so anything this old is not a live holder.\n */\nconst MUTEX_STALE_MS = 10_000\n\ninterface Payload {\n expiresAt: number\n value: unknown\n}\n\nconst now = (): number => Date.now()\n\nconst isLive = (payload: Payload | undefined): payload is Payload => payload !== undefined && payload.expiresAt > now()\n\nconst errorCode = (error: unknown): string | undefined => (error as NodeJS.ErrnoException).code\n\n/**\n * Store impl at `storage/framework/cache/data`: hashed paths, atomic writes (temp file + rename). Reads never\n * delete anything: an expired or corrupt file is simply a miss, and is replaced by the next write.\n */\nexport class FileStore implements Store {\n constructor(\n private readonly directory: string,\n private readonly keyPrefix: string = '',\n ) {}\n\n private path(key: string): string {\n const hash = createHash('sha1').update(this.keyPrefix + key).digest('hex')\n return join(this.directory, hash.slice(0, 2), hash.slice(2, 4), hash)\n }\n\n private tempPath(path: string): string {\n return `${path}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`\n }\n\n private encode(value: unknown, expiresAt: number): string {\n return `${String(expiresAt).padStart(13, '0')}${serialize(roundTrip(value))}`\n }\n\n /** Undefined for a missing or corrupt file; the payload (possibly expired) otherwise. */\n private async readPayload(path: string): Promise<Payload | undefined> {\n let raw: string\n try {\n raw = await readFile(path, 'utf8')\n } catch (error) {\n if (errorCode(error) === 'ENOENT') return undefined\n throw error\n }\n const header = raw.slice(0, 13)\n if (!/^\\d{13}$/.test(header)) return undefined\n try {\n return { expiresAt: Number(header), value: deserialize(raw.slice(13)) }\n } catch {\n return undefined\n }\n }\n\n private async writeTemp(path: string, contents: string): Promise<string> {\n await mkdir(dirname(path), { recursive: true })\n const temp = this.tempPath(path)\n await writeFile(temp, contents)\n return temp\n }\n\n private async atomicWrite(path: string, contents: string): Promise<void> {\n const temp = await this.writeTemp(path, contents)\n try {\n await rename(temp, path)\n } catch (error) {\n await rm(temp, { force: true })\n throw error\n }\n }\n\n async get(key: string): Promise<unknown> {\n const payload = await this.readPayload(this.path(key))\n return isLive(payload) ? payload.value : undefined\n }\n\n async many(keys: string[]): Promise<Record<string, unknown>> {\n const result: Record<string, unknown> = {}\n for (const key of keys) {\n const payload = await this.readPayload(this.path(key))\n if (isLive(payload)) result[key] = payload.value\n }\n return result\n }\n\n async put(key: string, value: unknown, seconds: number): Promise<boolean> {\n await this.atomicWrite(this.path(key), this.encode(value, now() + seconds * 1000))\n return true\n }\n\n async putForever(key: string, value: unknown): Promise<boolean> {\n await this.atomicWrite(this.path(key), this.encode(value, FOREVER))\n return true\n }\n\n /**\n * Exclusive create is the atomicity primitive, but the exclusive step is a hard link, not opening `path`\n * directly with `wx`: the full payload is written to a temp file first, then `link()`'d into place. `link()`\n * is atomic and fails `EEXIST` if the destination already exists, so no concurrent reader can ever observe a\n * half-written file at `path` — unlike creating `path` itself with `wx` and writing to it afterwards, which\n * leaves a window (between file creation and the write completing) where a concurrent `get()`/`add()` can read\n * an empty or truncated file and throw a JSON parse error instead of losing the race cleanly.\n *\n * If the key holds an expired or corrupt entry, the takeover happens under a per-key mutex (see\n * takeOverExpired), so two callers can never both replace it.\n */\n async add(key: string, value: unknown, seconds?: number): Promise<boolean> {\n const path = this.path(key)\n const expiresAt = seconds === undefined ? FOREVER : now() + seconds * 1000\n const temp = await this.writeTemp(path, this.encode(value, expiresAt))\n try {\n if (await this.linkExclusive(temp, path)) return true\n if (isLive(await this.readPayload(path))) return false\n return await this.takeOverExpired(path, temp)\n } finally {\n await rm(temp, { force: true })\n }\n }\n\n private async linkExclusive(from: string, to: string): Promise<boolean> {\n try {\n await link(from, to)\n return true\n } catch (error) {\n if (errorCode(error) === 'EEXIST') return false\n throw error\n }\n }\n\n /**\n * Replaces an expired or corrupt entry, holding `path + '.lock'` (created with the same link() trick) so only\n * one add() at a time can take it over. A caller that finds the mutex held loses without waiting: the holder\n * is replacing the entry right now, so at that moment the key is taken either way. Inside the mutex the entry\n * is re-read (it may have been replaced by a put() meanwhile), then removed and our file linked in: if anything\n * else creates the key in between (a put(), or an add() after a forget()), the link fails and we lose cleanly.\n */\n private async takeOverExpired(path: string, temp: string): Promise<boolean> {\n const mutex = `${path}.lock`\n const token = await this.acquireMutex(mutex)\n if (token === undefined) return false\n try {\n if (isLive(await this.readPayload(path))) return false\n await rm(path, { force: true })\n return await this.linkExclusive(temp, path)\n } finally {\n await this.releaseMutex(mutex, token)\n }\n }\n\n /** Returns our token once the mutex is held, or undefined if another live holder has it. */\n private async acquireMutex(mutex: string, retried = false): Promise<string | undefined> {\n const token = `${process.pid}-${Math.random().toString(36).slice(2)}`\n const temp = await this.writeTemp(mutex, token)\n try {\n if (await this.linkExclusive(temp, mutex)) return token\n } finally {\n await rm(temp, { force: true })\n }\n if (retried) return undefined\n let modified: number\n try {\n modified = (await stat(mutex)).mtimeMs\n } catch (error) {\n if (errorCode(error) === 'ENOENT') return this.acquireMutex(mutex, true) // released meanwhile\n throw error\n }\n if (now() - modified < MUTEX_STALE_MS) return undefined\n // Its holder crashed: clear it and try once more.\n await rm(mutex, { force: true })\n return this.acquireMutex(mutex, true)\n }\n\n /** Only removes the mutex if it is still ours (a stalled holder's mutex may have been cleared as stale). */\n private async releaseMutex(mutex: string, token: string): Promise<void> {\n try {\n if ((await readFile(mutex, 'utf8')) === token) await rm(mutex, { force: true })\n } catch (error) {\n if (errorCode(error) !== 'ENOENT') throw error\n }\n }\n\n async increment(key: string, by: number): Promise<number> {\n const path = this.path(key)\n const payload = await this.readPayload(path)\n const existing = isLive(payload) ? payload : undefined\n const current = existing && typeof existing.value === 'number' ? existing.value : 0\n const next = current + by\n await this.atomicWrite(path, this.encode(next, existing?.expiresAt ?? FOREVER))\n return next\n }\n\n decrement(key: string, by: number): Promise<number> {\n return this.increment(key, -by)\n }\n\n async forget(key: string): Promise<boolean> {\n try {\n await rm(this.path(key))\n return true\n } catch (error) {\n if (errorCode(error) === 'ENOENT') return false\n throw error\n }\n }\n\n /** Clears the whole directory, regardless of prefix — matches Laravel's FileStore::flush(). */\n async flush(): Promise<boolean> {\n await rm(this.directory, { recursive: true, force: true })\n await mkdir(this.directory, { recursive: true })\n return true\n }\n}\n","import type { DatabaseConnection } from '@orieljs/contracts'\n\n/**\n * Laravel's add()/acquire(): insert the row unless its key exists, and otherwise take the row over only when it has\n * expired. Returns whether the row is now this caller's. `row` holds the `key` and `expiration` columns.\n *\n * The insert never fails on a taken key (insertOrIgnore), so it can't abort the caller's transaction on Postgres and\n * needs no savepoint or queue: concurrent callers, in one transaction or in several, only wait on the database's own\n * row locks.\n */\nexport async function insertOrTakeOver(connection: DatabaseConnection, table: string, row: Record<string, unknown>): Promise<boolean> {\n if ((await connection.table(table).insertOrIgnore(row)) === 1) return true\n const now = Math.floor(Date.now() / 1000)\n return (await connection.table(table).where('key', row.key).where('expiration', '<=', now).update(row)) > 0\n}\n","import type { DatabaseConnection } from '@orieljs/contracts'\nimport { insertOrTakeOver } from '../insertOrTakeOver'\nimport { deserialize, roundTrip, serialize } from '../serialize'\nimport type { Store } from '../Store'\n\n/**\n * \"Forever\" here is a 10-year TTL from now, not a fixed epoch sentinel: `expiration` is an `integer` column\n * (Postgres/MySQL `int4`, max 2147483647), and the epoch-millisecond sentinel FileStore uses (9999999999999) overflows\n * it. This is Laravel's own DatabaseStore::forever(), which calls `put(key, value, 315360000)` for the same\n * reason, rather than a magic-number timestamp.\n */\nconst FOREVER_SECONDS = 315360000\n\ninterface CacheRow {\n key: string\n value: string\n expiration: number\n}\n\nconst now = (): number => Math.floor(Date.now() / 1000)\n\n/** Store impl over the `cache` table, resolved through DatabaseManager (never imports @orieljs/database). */\nexport class DatabaseStore implements Store {\n constructor(\n private readonly connection: DatabaseConnection,\n private readonly table: string,\n private readonly keyPrefix: string = '',\n ) {}\n\n private k(key: string): string {\n return this.keyPrefix + key\n }\n\n async get(key: string): Promise<unknown> {\n const k = this.k(key)\n const row = await this.connection.table<CacheRow>(this.table).where('key', k).first()\n if (!row) return undefined\n if (row.expiration <= now()) {\n // Only delete while still expired: another process may have rewritten the key since we read it.\n await this.connection.table(this.table).where('key', k).where('expiration', '<=', now()).delete()\n return undefined\n }\n return deserialize(row.value)\n }\n\n async many(keys: string[]): Promise<Record<string, unknown>> {\n if (keys.length === 0) return {}\n const prefixed = keys.map((key) => this.k(key))\n const rows = await this.connection.table<CacheRow>(this.table).whereIn('key', prefixed).get()\n const byKey = new Map(rows.all().map((row) => [row.key, row]))\n const time = now()\n const result: Record<string, unknown> = {}\n keys.forEach((key, i) => {\n const row = byKey.get(prefixed[i]!)\n if (row && row.expiration > time) result[key] = deserialize(row.value)\n })\n return result\n }\n\n async put(key: string, value: unknown, seconds: number): Promise<boolean> {\n return this.write(this.k(key), value, now() + Math.ceil(seconds))\n }\n\n async putForever(key: string, value: unknown): Promise<boolean> {\n return this.write(this.k(key), value, now() + FOREVER_SECONDS)\n }\n\n private async write(key: string, value: unknown, expiration: number): Promise<boolean> {\n await this.connection.table(this.table).upsert({ key, value: serialize(roundTrip(value)), expiration }, ['key'])\n return true\n }\n\n /**\n * Laravel's DatabaseStore::add(): an insert that skips a taken key, and then a conditional update that only takes\n * over an expired row (see insertOrTakeOver). Nothing fails on a taken key, so a caller's transaction stays usable.\n */\n async add(key: string, value: unknown, seconds?: number): Promise<boolean> {\n const k = this.k(key)\n const expiration = seconds === undefined ? now() + FOREVER_SECONDS : now() + Math.ceil(seconds)\n const row = { key: k, value: serialize(roundTrip(value)), expiration }\n return insertOrTakeOver(this.connection, this.table, row)\n }\n\n async increment(key: string, by: number, attempt = 0): Promise<number> {\n const k = this.k(key)\n try {\n return await this.connection.transaction(async (trx) => {\n const existing = await trx.table<CacheRow>(this.table).where('key', k).lockForUpdate().first()\n const unexpired = existing !== undefined && existing.expiration > now()\n const current = unexpired ? Number(deserialize(existing!.value)) : 0\n const next = current + by\n const expiration = unexpired ? existing!.expiration : now() + FOREVER_SECONDS\n const row = { key: k, value: serialize(next), expiration }\n if (existing) await trx.table(this.table).where('key', k).update(row)\n else await trx.table(this.table).insert(row)\n return next\n })\n } catch (error) {\n // Another writer's increment()/put() inserted this key between our lockForUpdate read (which saw no row)\n // and our own insert. Unlike add(), we can't just leave the other\n // writer's value alone — Store.ts requires increment() to apply `by` on top of whatever is there — so\n // retry the whole transaction once, this time reading the row the other writer just created. A second\n // failure propagates: something other than a benign insert race is going on.\n if (attempt > 0) throw error\n return this.increment(key, by, attempt + 1)\n }\n }\n\n decrement(key: string, by: number): Promise<number> {\n return this.increment(key, -by)\n }\n\n async forget(key: string): Promise<boolean> {\n const deleted = await this.connection.table(this.table).where('key', this.k(key)).delete()\n return deleted > 0\n }\n\n async flush(): Promise<boolean> {\n if (this.keyPrefix) await this.connection.table(this.table).where('key', 'like', `${this.keyPrefix}%`).delete()\n else await this.connection.table(this.table).delete()\n return true\n }\n}\n","import { setTimeout as sleep } from 'node:timers/promises'\nimport type { DatabaseConnection, Lock } from '@orieljs/contracts'\nimport { Str } from '@orieljs/support'\nimport { LockTimeoutError } from '../errors'\nimport { insertOrTakeOver } from '../insertOrTakeOver'\n\n// See DatabaseStore.ts: a 10-year TTL from now, not an epoch sentinel — `expiration` is an `integer` column and\n// FileStore's 9999999999999 sentinel overflows it on Postgres/MySQL (B8). Matches Laravel's DatabaseStore/DatabaseLock.\nconst FOREVER_SECONDS = 315360000\nconst now = (): number => Math.floor(Date.now() / 1000)\n\ninterface LockRow {\n key: string\n owner: string\n expiration: number\n}\n\n/**\n * Locks use their own `cache_locks` table (not `cache`), like Laravel's DatabaseLock: a `value` column with\n * arbitrary serialized data would make comparing owners awkward, so locks get dedicated `owner`/`expiration`\n * columns instead.\n */\nexport class DatabaseLock implements Lock {\n private readonly ownerValue: string\n\n constructor(\n private readonly connection: DatabaseConnection,\n private readonly table: string,\n private readonly name: string,\n private readonly seconds: number | undefined,\n owner?: string,\n private readonly pollMs = 50,\n ) {\n this.ownerValue = owner ?? Str.random(20)\n }\n\n owner(): string {\n return this.ownerValue\n }\n\n async get<T = boolean>(callback?: () => T | Promise<T>): Promise<T | false> {\n const acquired = await this.acquire()\n if (!acquired) return false\n if (!callback) return true as T\n try {\n return await callback()\n } finally {\n await this.release()\n }\n }\n\n async block<T = boolean>(seconds: number, callback?: () => T | Promise<T>): Promise<T | true> {\n const deadline = Date.now() + seconds * 1000\n for (;;) {\n if (await this.acquire()) break\n if (Date.now() >= deadline) throw new LockTimeoutError(this.name)\n await sleep(this.pollMs)\n }\n if (!callback) return true\n try {\n return await callback()\n } finally {\n await this.release()\n }\n }\n\n async release(): Promise<boolean> {\n return this.connection.transaction(async (trx) => {\n const existing = await trx.table<LockRow>(this.table).where('key', this.name).lockForUpdate().first()\n if (!existing || existing.owner !== this.ownerValue) return false\n await trx.table(this.table).where('key', this.name).delete()\n return true\n })\n }\n\n async forceRelease(): Promise<void> {\n await this.connection.table(this.table).where('key', this.name).delete()\n }\n\n /**\n * Laravel's DatabaseLock::acquire(): an insert that skips a taken key, and then a conditional update that only takes\n * over an expired lock (no re-entry for the same owner, like RedisLock); see insertOrTakeOver.\n */\n private async acquire(): Promise<boolean> {\n const expiration = this.seconds === undefined ? now() + FOREVER_SECONDS : now() + Math.ceil(this.seconds)\n const row = { key: this.name, owner: this.ownerValue, expiration }\n return insertOrTakeOver(this.connection, this.table, row)\n }\n}\n","/**\n * Text for `database/migrations/..._create_cache_table.ts`. Cache does not own migrations — Database does — so\n * this is plain text for the coordinator's Wave-1 C2 skeleton step to copy in, not code Cache compiles against.\n * Mirrors Laravel 11's default cache migration: one file, two tables. `expiration` stays a plain `integer`\n * (int4/int, max 2147483647): DatabaseStore/DatabaseLock's \"forever\" is a 10-year TTL from now\n * (`FOREVER_SECONDS`), never a fixed epoch sentinel, so it always fits (B8).\n */\nexport const CACHE_TABLE_MIGRATION = `import { Migration, Schema } from '@orieljs/framework'\n\nexport default class extends Migration {\n async up() {\n await Schema.create('cache', (t) => {\n t.string('key').primary()\n t.text('value')\n t.integer('expiration')\n })\n await Schema.create('cache_locks', (t) => {\n t.string('key').primary()\n t.string('owner')\n t.integer('expiration')\n })\n }\n\n async down() {\n await Schema.dropIfExists('cache_locks')\n await Schema.dropIfExists('cache')\n }\n}\n`\n","import { createHash, randomUUID } from 'node:crypto'\nimport Redis from 'ioredis'\nimport { deserialize, roundTrip, serialize } from '../serialize'\nimport type { Store } from '../Store'\n\nexport interface RedisConfig {\n /** A prebuilt ioredis instance. A string here (Laravel's `'client' => 'phpredis'` style) is ignored. */\n client?: Redis | string\n url?: string\n [option: string]: unknown\n}\n\n/**\n * Builds an ioredis client from cache.stores.redis config: a prebuilt client, or a URL and/or raw ioredis\n * options. With a URL, the remaining options (db, password, lazyConnect...) are still passed through.\n */\nexport function makeRedisClient(config: RedisConfig): Redis {\n if (typeof config.client === 'object' && config.client !== null) return config.client\n const { client: _client, url, driver: _driver, prefix: _prefix, connection: _connection, ...options } = config\n if (typeof url === 'string') return new Redis(url, options)\n return new Redis(options)\n}\n\n/** Shared low-level redis primitives, parameterized only by the fully-computed key. No prefixing here on purpose:\n * RedisStore and RedisTaggedStore each compute their own keys and never rely on ioredis's `keyPrefix` client\n * option (which doesn't rewrite SCAN's MATCH pattern, making prefixed flush()/tag-namespace lookups unreliable). */\nabstract class RedisPrimitives {\n protected constructor(protected readonly redis: Redis) {}\n\n protected async rawGet(key: string): Promise<unknown> {\n const raw = await this.redis.get(key)\n return raw === null ? undefined : deserialize(raw)\n }\n\n protected async rawMany(keys: string[]): Promise<Record<string, unknown>> {\n if (keys.length === 0) return {}\n const values = await this.redis.mget(...keys)\n const result: Record<string, unknown> = {}\n keys.forEach((key, i) => {\n const raw = values[i]\n if (raw !== null && raw !== undefined) result[key] = deserialize(raw)\n })\n return result\n }\n\n protected async rawPut(key: string, value: unknown, ms?: number): Promise<boolean> {\n if (ms === undefined) await this.redis.set(key, serialize(roundTrip(value)))\n else await this.redis.set(key, serialize(roundTrip(value)), 'PX', Math.max(1, Math.round(ms)))\n return true\n }\n\n protected async rawAdd(key: string, value: unknown, ms?: number): Promise<boolean> {\n const result =\n ms === undefined\n ? await this.redis.set(key, serialize(roundTrip(value)), 'NX')\n : await this.redis.set(key, serialize(roundTrip(value)), 'PX', Math.max(1, Math.round(ms)), 'NX')\n return result === 'OK'\n }\n\n protected rawIncrement(key: string, by: number): Promise<number> {\n return this.redis.incrby(key, by)\n }\n\n protected async rawForget(key: string): Promise<boolean> {\n return (await this.redis.del(key)) > 0\n }\n}\n\nexport class RedisStore extends RedisPrimitives implements Store {\n constructor(\n redis: Redis,\n private readonly keyPrefix: string = '',\n ) {\n super(redis)\n }\n\n private k(key: string): string {\n return this.keyPrefix + key\n }\n\n getPrefix(): string {\n return this.keyPrefix\n }\n\n get(key: string): Promise<unknown> {\n return this.rawGet(this.k(key))\n }\n\n async many(keys: string[]): Promise<Record<string, unknown>> {\n const prefixed = keys.map((key) => this.k(key))\n const found = await this.rawMany(prefixed)\n const result: Record<string, unknown> = {}\n keys.forEach((key, i) => {\n const p = prefixed[i]!\n if (p in found) result[key] = found[p]\n })\n return result\n }\n\n put(key: string, value: unknown, seconds: number): Promise<boolean> {\n return this.rawPut(this.k(key), value, seconds * 1000)\n }\n\n putForever(key: string, value: unknown): Promise<boolean> {\n return this.rawPut(this.k(key), value)\n }\n\n add(key: string, value: unknown, seconds?: number): Promise<boolean> {\n return this.rawAdd(this.k(key), value, seconds === undefined ? undefined : seconds * 1000)\n }\n\n increment(key: string, by: number): Promise<number> {\n return this.rawIncrement(this.k(key), by)\n }\n\n decrement(key: string, by: number): Promise<number> {\n return this.rawIncrement(this.k(key), -by)\n }\n\n forget(key: string): Promise<boolean> {\n return this.rawForget(this.k(key))\n }\n\n async flush(): Promise<boolean> {\n let cursor = '0'\n do {\n const [next, keys] = await this.redis.scan(cursor, 'MATCH', `${this.keyPrefix}*`, 'COUNT', 200)\n cursor = next\n if (keys.length > 0) await this.redis.unlink(...keys)\n } while (cursor !== '0')\n return true\n }\n\n tags(names: string[]): RedisTaggedStore {\n return new RedisTaggedStore(this.redis, this.keyPrefix, names)\n }\n}\n\n/**\n * A namespaced view of the same redis database. Every tag has a version (a random id); the namespace is a hash\n * of the sorted tag=version pairs. flush() bumps every tag's version, orphaning previously-namespaced entries\n * (they aren't deleted — they expire on their own TTL) — this is Laravel's actual TagSet::reset() behaviour.\n */\nexport class RedisTaggedStore extends RedisPrimitives implements Store {\n constructor(\n redis: Redis,\n private readonly keyPrefix: string,\n private readonly tagNames: string[],\n ) {\n super(redis)\n }\n\n private async tagVersion(name: string): Promise<string> {\n const key = `${this.keyPrefix}tag:${name}:version`\n const existing = await this.redis.get(key)\n if (existing !== null) return existing\n const version = randomUUID()\n const set = await this.redis.set(key, version, 'NX')\n return set === 'OK' ? version : ((await this.redis.get(key)) ?? version)\n }\n\n private async namespace(): Promise<string> {\n const versions = await Promise.all(this.tagNames.map((name) => this.tagVersion(name)))\n const joined = this.tagNames.map((name, i) => `${name}=${versions[i]}`).sort().join('|')\n return createHash('sha1').update(joined).digest('hex').slice(0, 16)\n }\n\n private async k(key: string): Promise<string> {\n return `${this.keyPrefix}tags:${await this.namespace()}:${key}`\n }\n\n async get(key: string): Promise<unknown> {\n return this.rawGet(await this.k(key))\n }\n\n async many(keys: string[]): Promise<Record<string, unknown>> {\n const prefixed = await Promise.all(keys.map((key) => this.k(key)))\n const found = await this.rawMany(prefixed)\n const result: Record<string, unknown> = {}\n keys.forEach((key, i) => {\n const p = prefixed[i]!\n if (p in found) result[key] = found[p]\n })\n return result\n }\n\n async put(key: string, value: unknown, seconds: number): Promise<boolean> {\n return this.rawPut(await this.k(key), value, seconds * 1000)\n }\n\n async putForever(key: string, value: unknown): Promise<boolean> {\n return this.rawPut(await this.k(key), value)\n }\n\n async add(key: string, value: unknown, seconds?: number): Promise<boolean> {\n return this.rawAdd(await this.k(key), value, seconds === undefined ? undefined : seconds * 1000)\n }\n\n async increment(key: string, by: number): Promise<number> {\n return this.rawIncrement(await this.k(key), by)\n }\n\n async decrement(key: string, by: number): Promise<number> {\n return this.rawIncrement(await this.k(key), -by)\n }\n\n async forget(key: string): Promise<boolean> {\n return this.rawForget(await this.k(key))\n }\n\n async flush(): Promise<boolean> {\n await Promise.all(this.tagNames.map((name) => this.redis.set(`${this.keyPrefix}tag:${name}:version`, randomUUID())))\n return true\n }\n}\n","import { setTimeout as sleep } from 'node:timers/promises'\nimport type { Lock } from '@orieljs/contracts'\nimport type Redis from 'ioredis'\nimport { Str } from '@orieljs/support'\nimport { LockTimeoutError } from '../errors'\n\nconst RELEASE_SCRIPT = 'if redis.call(\"get\", KEYS[1]) == ARGV[1] then return redis.call(\"del\", KEYS[1]) else return 0 end'\n\n/** SET key value [PX ms] NX to acquire; a Lua script to release only if we still own it (compare-and-delete). */\nexport class RedisLock implements Lock {\n private readonly ownerValue: string\n\n constructor(\n private readonly redis: Redis,\n private readonly name: string,\n private readonly seconds: number | undefined,\n owner?: string,\n private readonly pollMs = 50,\n ) {\n this.ownerValue = owner ?? Str.random(20)\n }\n\n owner(): string {\n return this.ownerValue\n }\n\n async get<T = boolean>(callback?: () => T | Promise<T>): Promise<T | false> {\n const acquired = await this.acquire()\n if (!acquired) return false\n if (!callback) return true as T\n try {\n return await callback()\n } finally {\n await this.release()\n }\n }\n\n async block<T = boolean>(seconds: number, callback?: () => T | Promise<T>): Promise<T | true> {\n const deadline = Date.now() + seconds * 1000\n for (;;) {\n if (await this.acquire()) break\n if (Date.now() >= deadline) throw new LockTimeoutError(this.name)\n await sleep(this.pollMs)\n }\n if (!callback) return true\n try {\n return await callback()\n } finally {\n await this.release()\n }\n }\n\n async release(): Promise<boolean> {\n const result = await this.redis.eval(RELEASE_SCRIPT, 1, this.name, this.ownerValue)\n return result === 1\n }\n\n async forceRelease(): Promise<void> {\n await this.redis.del(this.name)\n }\n\n private async acquire(): Promise<boolean> {\n const result =\n this.seconds === undefined\n ? await this.redis.set(this.name, this.ownerValue, 'NX')\n : await this.redis.set(this.name, this.ownerValue, 'PX', Math.max(1, Math.round(this.seconds * 1000)), 'NX')\n return result === 'OK'\n }\n}\n","import type { CacheRepository } from '@orieljs/contracts'\nimport type Redis from 'ioredis'\nimport { RedisLock } from '../locks/RedisLock'\nimport { Repository } from '../Repository'\nimport { RedisStore } from './RedisStore'\n\n/** Each client's QUIT, from the first store that sends it until the connection has closed. */\nconst quitting = new WeakMap<Redis, Promise<void>>()\n\n/** The only Repository subclass: the only store where tags() doesn't throw. */\nexport class RedisRepository extends Repository {\n constructor(\n private readonly redisStore: RedisStore,\n private readonly redis: Redis,\n ) {\n // Lock keys carry the store's prefix, like every cache key (and like Laravel's RedisStore::lock()).\n super(redisStore, (_store, name, seconds, owner) => new RedisLock(redis, redisStore.getPrefix() + name, seconds, owner))\n }\n\n /**\n * Closes the redis client (CacheManager.disconnectAll() at shutdown): a connected one with QUIT, one that never\n * connected or is reconnecting without waiting; one already closed is left alone. A client two stores share is quit\n * once: QUIT resolves on the server's reply, but the client reads 'ready' until its socket closes, so the second\n * store waits on the first one's QUIT instead of sending another (which would fail with \"Connection is closed.\").\n */\n async disconnect(): Promise<void> {\n const redis = this.redis\n const pending = quitting.get(redis)\n if (pending) return pending\n if (redis.status === 'end') return\n if (redis.status !== 'ready') return redis.disconnect()\n const quit = redis.quit().then(() => undefined)\n quitting.set(redis, quit)\n // Forgotten once closed, so a client connected again later is quit again.\n redis.once('end', () => quitting.delete(redis))\n return quit\n }\n\n override tags(names: string | string[]): CacheRepository {\n const list = Array.isArray(names) ? names : [names]\n const taggedStore = this.redisStore.tags(list)\n // Tagged locks use the same base prefix: tags namespace entries, not locks.\n const prefix = this.redisStore.getPrefix()\n return new Repository(taggedStore, (_store, name, seconds, owner) => new RedisLock(this.redis, prefix + name, seconds, owner))\n }\n}\n","import type { CacheRepository, Container } from '@orieljs/contracts'\nimport { CacheManager as CacheManagerToken, ConfigRepository, DatabaseManager } from '@orieljs/contracts'\nimport { UnknownCacheDriverError, UnknownCacheStoreError } from './errors'\nimport { DatabaseLock } from './locks/DatabaseLock'\nimport { Repository } from './Repository'\nimport { DatabaseStore } from './stores/DatabaseStore'\nimport { FileStore } from './stores/FileStore'\nimport { MemoryStore } from './stores/MemoryStore'\nimport { makeRedisClient, RedisStore } from './stores/RedisStore'\nimport { RedisRepository } from './stores/RedisRepository'\n\ntype StoreConfig = Record<string, unknown>\ntype Driver = (config: StoreConfig) => CacheRepository\n\n/**\n * Resolves the ioredis config for the `redis` cache driver, as a pure function so the fallback logic is testable\n * without a real redis connection. An inline `url` or client instance on `cache.stores.redis` wins and is passed straight\n * through; otherwise this falls back to `database.redis.<connection ?? 'default'>` (U3, Laravel's own\n * convention) — Session and Queue's redis connections resolve the exact same way, so one `database.redis`\n * config block covers every component that needs redis.\n */\nexport function resolveRedisConfig(cfg: StoreConfig, lookupDatabaseRedis: (connectionName: string) => StoreConfig): StoreConfig {\n const hasClient = typeof cfg.client === 'object' && cfg.client !== null\n if (cfg.url !== undefined || hasClient) return cfg\n const connectionName = (cfg.connection as string | undefined) ?? 'default'\n return { ...lookupDatabaseRedis(connectionName), ...cfg }\n}\n\ninterface CacheConfig {\n default: string\n prefix?: string\n stores: Record<string, StoreConfig>\n}\n\nexport class CacheManager implements CacheManagerToken {\n private readonly stores = new Map<string, CacheRepository>()\n private readonly drivers = new Map<string, Driver>()\n\n constructor(private readonly container: Container) {\n this.drivers.set('memory', (cfg) => new Repository(new MemoryStore(this.str(cfg.prefix), cfg.maxItems as number | undefined)))\n this.drivers.set('array', (cfg) => new Repository(new MemoryStore(this.str(cfg.prefix))))\n this.drivers.set('file', (cfg) => new Repository(new FileStore(cfg.path as string, this.str(cfg.prefix))))\n this.drivers.set('database', (cfg) => this.buildDatabaseStore(cfg))\n this.drivers.set('redis', (cfg) => this.buildRedisStore(cfg))\n }\n\n private str(value: unknown): string {\n return typeof value === 'string' ? value : ''\n }\n\n private cacheConfig(): CacheConfig {\n return this.container.make(ConfigRepository).get<CacheConfig>('cache', { default: 'database', stores: {} })\n }\n\n private buildDatabaseStore(cfg: StoreConfig): CacheRepository {\n const connection = this.container.make(DatabaseManager).connection(cfg.connection as string | undefined)\n const table = (cfg.table as string | undefined) ?? 'cache'\n const lockTable = (cfg.lockTable as string | undefined) ?? 'cache_locks'\n const prefix = this.str(cfg.prefix)\n const store = new DatabaseStore(connection, table, prefix)\n // Lock names carry the store's prefix, like every cache key (and like Laravel's DatabaseStore::lock()).\n return new Repository(store, (_store, name, seconds, owner) => new DatabaseLock(connection, lockTable, prefix + name, seconds, owner))\n }\n\n private buildRedisStore(cfg: StoreConfig): CacheRepository {\n const resolved = resolveRedisConfig(cfg, (connectionName) =>\n this.container.make(ConfigRepository).get<StoreConfig>(`database.redis.${connectionName}`, {}),\n )\n const redis = makeRedisClient(resolved)\n const store = new RedisStore(redis, this.str(cfg.prefix))\n return new RedisRepository(store, redis)\n }\n\n store(name?: string): CacheRepository {\n const cacheConfig = this.cacheConfig()\n const storeName = name ?? cacheConfig.default\n let repository = this.stores.get(storeName)\n if (!repository) {\n const storeConfig = cacheConfig.stores[storeName]\n if (!storeConfig) throw new UnknownCacheStoreError(storeName)\n const driverName = storeConfig.driver as string | undefined\n const driver = driverName ? this.drivers.get(driverName) : undefined\n if (!driver) throw new UnknownCacheDriverError(String(driverName))\n repository = driver({ ...storeConfig, prefix: storeConfig.prefix ?? cacheConfig.prefix ?? '' })\n this.stores.set(storeName, repository)\n }\n return repository\n }\n\n /**\n * Closes the redis clients of the stores resolved so far and forgets the stores, so the next use builds them again\n * (the app's shutdown calls it). Stores without a connection to close are only forgotten. A store that fails to\n * close doesn't keep the others open: all are closed, then its error is thrown (several: an AggregateError).\n */\n async disconnectAll(): Promise<void> {\n const stores = [...this.stores.values()]\n this.stores.clear()\n const results = await Promise.allSettled(\n stores.map(async (store) => (store as CacheRepository & { disconnect?(): Promise<void> }).disconnect?.()),\n )\n // A set: two stores sharing a client whose QUIT failed report that one error once.\n const errors = [...new Set(results.flatMap((result) => (result.status === 'rejected' ? [result.reason as unknown] : [])))]\n if (errors.length === 1) throw errors[0]\n if (errors.length > 1) throw new AggregateError(errors, `${errors.length} cache stores failed to close.`)\n }\n\n extend(driver: string, factory: Driver): void {\n this.drivers.set(driver, factory)\n }\n\n get<T = unknown>(key: string, defaultValue?: T | (() => T)): Promise<T | undefined> {\n return defaultValue === undefined ? this.store().get<T>(key) : this.store().get<T>(key, defaultValue)\n }\n many<T = unknown>(keys: string[]): Promise<Record<string, T | undefined>> {\n return this.store().many<T>(keys)\n }\n has(key: string): Promise<boolean> {\n return this.store().has(key)\n }\n missing(key: string): Promise<boolean> {\n return this.store().missing(key)\n }\n put(key: string, value: unknown, ttlSeconds?: number): Promise<boolean> {\n return this.store().put(key, value, ttlSeconds)\n }\n add(key: string, value: unknown, ttlSeconds?: number): Promise<boolean> {\n return this.store().add(key, value, ttlSeconds)\n }\n increment(key: string, by?: number): Promise<number> {\n return this.store().increment(key, by)\n }\n decrement(key: string, by?: number): Promise<number> {\n return this.store().decrement(key, by)\n }\n forever(key: string, value: unknown): Promise<boolean> {\n return this.store().forever(key, value)\n }\n pull<T = unknown>(key: string, defaultValue?: T): Promise<T | undefined> {\n return this.store().pull<T>(key, defaultValue)\n }\n forget(key: string): Promise<boolean> {\n return this.store().forget(key)\n }\n flush(): Promise<boolean> {\n return this.store().flush()\n }\n remember<T>(key: string, ttlSeconds: number, callback: () => T | Promise<T>): Promise<T> {\n return this.store().remember(key, ttlSeconds, callback)\n }\n rememberForever<T>(key: string, callback: () => T | Promise<T>): Promise<T> {\n return this.store().rememberForever(key, callback)\n }\n lock(name: string, seconds?: number, owner?: string) {\n return this.store().lock(name, seconds, owner)\n }\n tags(names: string | string[]): CacheRepository {\n return this.store().tags(names)\n }\n}\n","import type { CacheRepository, RateLimiter } from '@orieljs/contracts'\n\nconst now = (): number => Math.floor(Date.now() / 1000)\n\n/**\n * Laravel's Illuminate\\Cache\\RateLimiter over a cache store: `<key>` holds the hit count and `<key>:timer` the unix\n * time the window ends, both expiring with the window. The store is resolved on every call, so a store swapped in\n * a test (or config changed at run time) is the one used.\n */\nexport class CacheRateLimiter implements RateLimiter {\n constructor(private readonly store: () => CacheRepository) {}\n\n async tooManyAttempts(key: string, maxAttempts: number): Promise<boolean> {\n const clean = this.cleanKey(key)\n if ((await this.#attempts(clean)) >= maxAttempts) {\n if (await this.store().has(`${clean}:timer`)) return true\n await this.store().forget(clean)\n }\n return false\n }\n\n async hit(key: string, decaySeconds = 60): Promise<number> {\n const clean = this.cleanKey(key)\n const cache = this.store()\n await cache.add(`${clean}:timer`, now() + decaySeconds, decaySeconds)\n const added = await cache.add(clean, 0, decaySeconds)\n const hits = await cache.increment(clean)\n // The count expired between add() and increment(), which then stored it forever: give it the window again.\n if (!added && hits === 1) await cache.put(clean, 1, decaySeconds)\n return hits\n }\n\n attempts(key: string): Promise<number> {\n return this.#attempts(this.cleanKey(key))\n }\n\n async remaining(key: string, maxAttempts: number): Promise<number> {\n return Math.max(0, maxAttempts - (await this.#attempts(this.cleanKey(key))))\n }\n\n async availableIn(key: string): Promise<number> {\n const timer = await this.store().get<number>(`${this.cleanKey(key)}:timer`)\n return timer === undefined ? 0 : Math.max(0, Number(timer) - now())\n }\n\n async clear(key: string): Promise<void> {\n const clean = this.cleanKey(key)\n await this.store().forget(clean)\n await this.store().forget(`${clean}:timer`)\n }\n\n /** Laravel's cleanRateLimiterKey(): accented letters become their plain letter ('zoë' and 'zoe' share a key). */\n protected cleanKey(key: string): string {\n return key.normalize('NFKD').replace(/[̀-ͯ]/g, '')\n }\n\n async #attempts(clean: string): Promise<number> {\n return Number((await this.store().get<number>(clean)) ?? 0)\n }\n}\n","import type { CacheManager, RateLimiter as RateLimiterContract } from '@orieljs/contracts'\nimport { CacheManager as CacheManagerToken, RateLimiter as RateLimiterToken } from '@orieljs/contracts'\nimport { inject } from '@orieljs/container'\nimport { facade } from '@orieljs/support'\n\nexport const Cache = facade<CacheManager>(CacheManagerToken)\n\n/** The RateLimiter facade: RateLimiter.tooManyAttempts(key, 5), RateLimiter.hit(key), RateLimiter.clear(key). */\nexport const RateLimiter = facade<RateLimiterContract>(RateLimiterToken)\n\nexport function cache(): CacheManager\nexport function cache(key: string): Promise<unknown>\nexport function cache(values: Record<string, unknown>, ttlSeconds?: number): Promise<boolean>\nexport function cache(arg?: string | Record<string, unknown>, ttlSeconds?: number): unknown {\n const manager = inject(CacheManagerToken)\n if (arg === undefined) return manager\n if (typeof arg === 'string') return manager.get(arg)\n return Promise.all(Object.entries(arg).map(([key, value]) => manager.put(key, value, ttlSeconds))).then((results) =>\n results.every(Boolean),\n )\n}\n","import { CacheManager as CacheManagerToken, ConfigRepository, RateLimiter } from '@orieljs/contracts'\nimport { ServiceProvider } from '@orieljs/support'\nimport { CacheManager } from './CacheManager'\nimport { CacheRateLimiter } from './RateLimiter'\n\nexport class CacheServiceProvider extends ServiceProvider {\n override register(): void {\n this.mergeConfigFrom(\n {\n default: 'database',\n prefix: '',\n stores: {\n array: { driver: 'array' },\n memory: { driver: 'memory' },\n file: { driver: 'file', path: this.app.storagePath('framework/cache/data') },\n database: { driver: 'database', table: 'cache', lockTable: 'cache_locks' },\n // Resolved from `database.redis.cache` (its own db), not `default`: flush() scans every key under the\n // prefix, so sharing a db with Queue or Session would wipe their keys too.\n redis: { driver: 'redis', connection: 'cache' },\n },\n },\n 'cache',\n )\n this.app.singleton(CacheManagerToken, (container) => new CacheManager(container))\n // At the end of the process: quit the redis clients the stores opened (never builds a manager to do it).\n this.app.onShutdown(async () => {\n if (!this.app.resolved(CacheManagerToken)) return\n await (this.app.make(CacheManagerToken) as { disconnectAll?(): Promise<void> }).disconnectAll?.()\n })\n // Laravel: the store named by cache.limiter, else the default store.\n this.app.singleton(RateLimiter, (container) => {\n return new CacheRateLimiter(() => {\n const name = container.make(ConfigRepository).get<string | undefined>('cache.limiter', undefined)\n return container.make(CacheManagerToken).store(name === undefined || name === '' ? undefined : name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AAA,IAClG,CAAC;AAED,SAAK,IAAI,UAAUC,cAAa,CAAC,cAAc;AAC7C,aAAO,IAAI,iBAAiB,MAAM;AAChC,cAAM,OAAO,UAAU,KAAKC,iBAAgB,EAAE,IAAwB,iBAAiB,MAAS;AAChG,eAAO,UAAU,KAAKF,kBAAiB,EAAE,MAAM,SAAS,UAAa,SAAS,KAAK,SAAY,IAAI;AAAA,MACrG,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AACF;","names":["now","now","sleep","Str","FOREVER_SECONDS","now","Str","sleep","createHash","createHash","sleep","Str","Str","sleep","now","cache","CacheManagerToken","CacheManagerToken","ConfigRepository","RateLimiter","CacheManagerToken","RateLimiter","ConfigRepository"]}
|
|
1
|
+
{"version":3,"sources":["../errors.ts","../serialize.ts","../locks/GenericLock.ts","../Repository.ts","../stores/MemoryStore.ts","../stores/FileStore.ts","../insertOrTakeOver.ts","../stores/DatabaseStore.ts","../locks/DatabaseLock.ts","../migrations.ts","../stores/RedisStore.ts","../locks/RedisLock.ts","../stores/RedisRepository.ts","../CacheManager.ts","../RateLimiter.ts","../RateLimiting/Limit.ts","../facade.ts","../CacheServiceProvider.ts","../commands.ts"],"sourcesContent":["import type { OrielError } from '@orieljs/contracts'\n\nexport class LockTimeoutError extends Error implements OrielError {\n readonly kind = 'Server' as const\n readonly status = 500\n override readonly name = 'LockTimeoutError'\n constructor(readonly lockName: string) {\n super(`Unable to acquire lock [${lockName}].`)\n }\n}\n\nexport class TagsNotSupportedError extends Error implements OrielError {\n readonly kind = 'Server' as const\n readonly status = 500\n override readonly name = 'TagsNotSupportedError'\n constructor(store: string) {\n super(`The [${store}] cache store does not support tags. Only the redis store does.`)\n }\n}\n\nexport class UnknownCacheStoreError extends Error implements OrielError {\n readonly kind = 'Server' as const\n readonly status = 500\n override readonly name = 'UnknownCacheStoreError'\n constructor(name: string) {\n super(`Cache store [${name}] is not configured. Add it to config('cache.stores').`)\n }\n}\n\nexport class UnknownCacheDriverError extends Error implements OrielError {\n readonly kind = 'Server' as const\n readonly status = 500\n override readonly name = 'UnknownCacheDriverError'\n constructor(driver: string) {\n super(`Cache driver [${driver}] is not supported. Register it first with CacheManager.extend().`)\n }\n}\n\nexport class InvalidCacheConfigError extends Error implements OrielError {\n readonly kind = 'Server' as const\n readonly status = 500\n override readonly name = 'InvalidCacheConfigError'\n}\n","/**\n * Cache values always round-trip through JSON.stringify/JSON.parse, on every store — even the in-process\n * memory store — so switching `cache.default` never changes behaviour. Practical limits this implies:\n * - A Date becomes a string (ISO 8601). Read it back with `new Date(...)`, or use a Model cast.\n * - undefined properties on an object are dropped, and a bare `undefined` value is stored as `null` (it reads\n * back as `null`, not as a miss: `undefined` is only ever the \"cache miss\" result of a read).\n * - NaN and Infinity become `null`.\n * - Map, Set, class instances, functions and symbols do not round-trip: plain data only.\n */\nexport function serialize(value: unknown): string {\n return JSON.stringify(value) ?? 'null'\n}\n\nexport function deserialize(raw: string): unknown {\n return JSON.parse(raw)\n}\n\n/** Deep-clones `value` through JSON, applying the same limits as every persisted store. */\nexport function roundTrip<T>(value: T): T {\n return JSON.parse(serialize(value)) as T\n}\n","import { setTimeout as sleep } from 'node:timers/promises'\nimport type { Lock } from '@orieljs/contracts'\nimport { Str } from '@orieljs/support'\nimport { LockTimeoutError } from '../errors'\nimport type { Store } from '../Store'\n\n/**\n * Backs a Lock with any Store whose add() is atomic (memory, array, file). Shares the store's key space with\n * regular cache entries, exactly like Laravel's CacheLock: `Cache::lock('x')` and `Cache::put('x', ...)` name the\n * same slot on purpose.\n */\nexport class GenericLock implements Lock {\n private readonly ownerValue: string\n\n constructor(\n private readonly store: Store,\n private readonly name: string,\n private readonly seconds: number | undefined,\n owner?: string,\n private readonly pollMs = 50,\n ) {\n this.ownerValue = owner ?? Str.random(20)\n }\n\n owner(): string {\n return this.ownerValue\n }\n\n async get<T = boolean>(callback?: () => T | Promise<T>): Promise<T | false> {\n const acquired = await this.store.add(this.name, this.ownerValue, this.seconds)\n if (!acquired) return false\n if (!callback) return true as T\n try {\n return await callback()\n } finally {\n await this.release()\n }\n }\n\n async block<T = boolean>(seconds: number, callback?: () => T | Promise<T>): Promise<T | true> {\n const deadline = Date.now() + seconds * 1000\n for (;;) {\n if (await this.get()) break\n if (Date.now() >= deadline) throw new LockTimeoutError(this.name)\n await sleep(this.pollMs)\n }\n if (!callback) return true\n try {\n return await callback()\n } finally {\n await this.release()\n }\n }\n\n async release(): Promise<boolean> {\n const current = await this.store.get(this.name)\n if (current !== this.ownerValue) return false\n return this.store.forget(this.name)\n }\n\n async forceRelease(): Promise<void> {\n await this.store.forget(this.name)\n }\n}\n","import type { CacheRepository, Lock } from '@orieljs/contracts'\nimport { GenericLock } from './locks/GenericLock'\nimport { TagsNotSupportedError } from './errors'\nimport type { Store } from './Store'\n\nexport type LockFactory = (store: Store, name: string, seconds: number | undefined, owner: string | undefined) => Lock\n\nexport const defaultLockFactory: LockFactory = (store, name, seconds, owner) => new GenericLock(store, name, seconds, owner)\n\n/** Implements the full CacheRepository API over any Store, the way Illuminate\\Cache\\Repository wraps a Store. */\nexport class Repository implements CacheRepository {\n constructor(\n protected readonly store: Store,\n private readonly lockFactory: LockFactory = defaultLockFactory,\n ) {}\n\n async get<T = unknown>(key: string, defaultValue?: T | (() => T)): Promise<T | undefined> {\n const value = await this.store.get(key)\n if (value !== undefined) return value as T\n return typeof defaultValue === 'function' ? (defaultValue as () => T)() : defaultValue\n }\n\n async many<T = unknown>(keys: string[]): Promise<Record<string, T | undefined>> {\n const found = await this.store.many(keys)\n const result: Record<string, T | undefined> = {}\n for (const key of keys) result[key] = found[key] as T | undefined\n return result\n }\n\n async has(key: string): Promise<boolean> {\n return (await this.store.get(key)) !== undefined\n }\n\n async missing(key: string): Promise<boolean> {\n return !(await this.has(key))\n }\n\n async put(key: string, value: unknown, ttlSeconds?: number): Promise<boolean> {\n if (ttlSeconds !== undefined && ttlSeconds <= 0) {\n await this.store.forget(key)\n return true\n }\n if (ttlSeconds === undefined) return this.store.putForever(key, value)\n return this.store.put(key, value, ttlSeconds)\n }\n\n async add(key: string, value: unknown, ttlSeconds?: number): Promise<boolean> {\n if (ttlSeconds !== undefined && ttlSeconds <= 0) return false\n return this.store.add(key, value, ttlSeconds)\n }\n\n increment(key: string, by = 1): Promise<number> {\n return this.store.increment(key, by)\n }\n\n decrement(key: string, by = 1): Promise<number> {\n return this.store.decrement(key, by)\n }\n\n forever(key: string, value: unknown): Promise<boolean> {\n return this.store.putForever(key, value)\n }\n\n async pull<T = unknown>(key: string, defaultValue?: T): Promise<T | undefined> {\n const value = await this.get<T>(key)\n await this.forget(key)\n return value === undefined ? defaultValue : value\n }\n\n forget(key: string): Promise<boolean> {\n return this.store.forget(key)\n }\n\n flush(): Promise<boolean> {\n return this.store.flush()\n }\n\n async remember<T>(key: string, ttlSeconds: number, callback: () => T | Promise<T>): Promise<T> {\n const cached = await this.get<T>(key)\n if (cached !== undefined) return cached\n const value = await callback()\n if (value !== undefined) await this.put(key, value, ttlSeconds)\n return value\n }\n\n async rememberForever<T>(key: string, callback: () => T | Promise<T>): Promise<T> {\n const cached = await this.get<T>(key)\n if (cached !== undefined) return cached\n const value = await callback()\n if (value !== undefined) await this.forever(key, value)\n return value\n }\n\n lock(name: string, seconds?: number, owner?: string): Lock {\n // Laravel's semantics: 0 (and anything <= 0) seconds means \"no expiry\", exactly like `undefined`. Locks are\n // always positive-duration in practice, but callers that compute `uniqueFor ?? 0` (Bus's UniqueLock, for\n // example) need `lock(key, 0)` to behave the same as `lock(key)`, not to expire immediately.\n const normalizedSeconds = seconds !== undefined && seconds <= 0 ? undefined : seconds\n return this.lockFactory(this.store, name, normalizedSeconds, owner)\n }\n\n tags(_names: string | string[]): CacheRepository {\n throw new TagsNotSupportedError(this.store.constructor.name)\n }\n}\n","import { InvalidCacheConfigError } from '../errors'\nimport { roundTrip } from '../serialize'\nimport type { Store } from '../Store'\n\ninterface Entry {\n value: unknown\n expiresAt: number | undefined\n}\n\n/**\n * Backs both the `memory` and `array` drivers: `array` is just a MemoryStore with no `maxItems` bound.\n * A bounded store evicts least-recently-used entries, and that includes held locks (GenericLock keys).\n */\nexport class MemoryStore implements Store {\n private readonly entries = new Map<string, Entry>()\n\n constructor(\n private readonly keyPrefix: string = '',\n private readonly maxItems?: number,\n ) {\n if (maxItems !== undefined && !(maxItems >= 1)) {\n throw new InvalidCacheConfigError(`Memory cache maxItems must be at least 1, got [${maxItems}].`)\n }\n }\n\n private k(key: string): string {\n return this.keyPrefix + key\n }\n\n /** Reads and, on a hit, re-inserts the entry so Map iteration order tracks recency (a simple LRU). */\n private read(key: string): Entry | undefined {\n const entry = this.entries.get(key)\n if (!entry) return undefined\n if (entry.expiresAt !== undefined && entry.expiresAt <= Date.now()) {\n this.entries.delete(key)\n return undefined\n }\n this.entries.delete(key)\n this.entries.set(key, entry)\n return entry\n }\n\n private write(key: string, value: unknown, expiresAt: number | undefined): void {\n this.entries.delete(key)\n this.entries.set(key, { value: roundTrip(value), expiresAt })\n if (this.maxItems !== undefined) {\n while (this.entries.size > this.maxItems) {\n const oldest = this.entries.keys().next().value\n if (oldest === undefined) break\n this.entries.delete(oldest)\n }\n }\n }\n\n async get(key: string): Promise<unknown> {\n return this.read(this.k(key))?.value\n }\n\n async many(keys: string[]): Promise<Record<string, unknown>> {\n const result: Record<string, unknown> = {}\n for (const key of keys) {\n const entry = this.read(this.k(key))\n if (entry) result[key] = entry.value\n }\n return result\n }\n\n async put(key: string, value: unknown, seconds: number): Promise<boolean> {\n this.write(this.k(key), value, Date.now() + seconds * 1000)\n return true\n }\n\n async putForever(key: string, value: unknown): Promise<boolean> {\n this.write(this.k(key), value, undefined)\n return true\n }\n\n async add(key: string, value: unknown, seconds?: number): Promise<boolean> {\n const k = this.k(key)\n if (this.read(k) !== undefined) return false\n this.write(k, value, seconds === undefined ? undefined : Date.now() + seconds * 1000)\n return true\n }\n\n async increment(key: string, by: number): Promise<number> {\n const k = this.k(key)\n const existing = this.read(k)\n const current = typeof existing?.value === 'number' ? existing.value : 0\n const next = current + by\n this.write(k, next, existing?.expiresAt)\n return next\n }\n\n async decrement(key: string, by: number): Promise<number> {\n return this.increment(key, -by)\n }\n\n async forget(key: string): Promise<boolean> {\n return this.entries.delete(this.k(key))\n }\n\n async flush(): Promise<boolean> {\n this.entries.clear()\n return true\n }\n}\n","import { createHash } from 'node:crypto'\nimport { link, mkdir, readFile, rename, rm, stat, writeFile } from 'node:fs/promises'\nimport { dirname, join } from 'node:path'\nimport { deserialize, roundTrip, serialize } from '../serialize'\nimport type { Store } from '../Store'\n\n/**\n * Unix-milliseconds sentinel for \"forever\" (13 digits, year 2286 — the same horizon as Laravel's FileStore\n * sentinel, just in milliseconds instead of seconds). Millisecond, not second, resolution: the test suite (and\n * Console's scheduler, which can pass sub-second-rounding-sensitive TTLs) relies on short TTLs like 0.05s\n * actually expiring within tens of milliseconds, which a whole-seconds timestamp can't represent.\n */\nconst FOREVER = 9999999999999\n\n/**\n * How old a key's takeover mutex file must be before another process may assume its holder crashed. The\n * critical section it guards is one small read plus a rename, so anything this old is not a live holder.\n */\nconst MUTEX_STALE_MS = 10_000\n\ninterface Payload {\n expiresAt: number\n value: unknown\n}\n\nconst now = (): number => Date.now()\n\nconst isLive = (payload: Payload | undefined): payload is Payload => payload !== undefined && payload.expiresAt > now()\n\nconst errorCode = (error: unknown): string | undefined => (error as NodeJS.ErrnoException).code\n\n/**\n * Store impl at `storage/framework/cache/data`: hashed paths, atomic writes (temp file + rename). Reads never\n * delete anything: an expired or corrupt file is simply a miss, and is replaced by the next write.\n */\nexport class FileStore implements Store {\n constructor(\n private readonly directory: string,\n private readonly keyPrefix: string = '',\n ) {}\n\n private path(key: string): string {\n const hash = createHash('sha1').update(this.keyPrefix + key).digest('hex')\n return join(this.directory, hash.slice(0, 2), hash.slice(2, 4), hash)\n }\n\n private tempPath(path: string): string {\n return `${path}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`\n }\n\n private encode(value: unknown, expiresAt: number): string {\n return `${String(expiresAt).padStart(13, '0')}${serialize(roundTrip(value))}`\n }\n\n /** Undefined for a missing or corrupt file; the payload (possibly expired) otherwise. */\n private async readPayload(path: string): Promise<Payload | undefined> {\n let raw: string\n try {\n raw = await readFile(path, 'utf8')\n } catch (error) {\n if (errorCode(error) === 'ENOENT') return undefined\n throw error\n }\n const header = raw.slice(0, 13)\n if (!/^\\d{13}$/.test(header)) return undefined\n try {\n return { expiresAt: Number(header), value: deserialize(raw.slice(13)) }\n } catch {\n return undefined\n }\n }\n\n private async writeTemp(path: string, contents: string): Promise<string> {\n await mkdir(dirname(path), { recursive: true })\n const temp = this.tempPath(path)\n await writeFile(temp, contents)\n return temp\n }\n\n private async atomicWrite(path: string, contents: string): Promise<void> {\n const temp = await this.writeTemp(path, contents)\n try {\n await rename(temp, path)\n } catch (error) {\n await rm(temp, { force: true })\n throw error\n }\n }\n\n async get(key: string): Promise<unknown> {\n const payload = await this.readPayload(this.path(key))\n return isLive(payload) ? payload.value : undefined\n }\n\n async many(keys: string[]): Promise<Record<string, unknown>> {\n const result: Record<string, unknown> = {}\n for (const key of keys) {\n const payload = await this.readPayload(this.path(key))\n if (isLive(payload)) result[key] = payload.value\n }\n return result\n }\n\n async put(key: string, value: unknown, seconds: number): Promise<boolean> {\n await this.atomicWrite(this.path(key), this.encode(value, now() + seconds * 1000))\n return true\n }\n\n async putForever(key: string, value: unknown): Promise<boolean> {\n await this.atomicWrite(this.path(key), this.encode(value, FOREVER))\n return true\n }\n\n /**\n * Exclusive create is the atomicity primitive, but the exclusive step is a hard link, not opening `path`\n * directly with `wx`: the full payload is written to a temp file first, then `link()`'d into place. `link()`\n * is atomic and fails `EEXIST` if the destination already exists, so no concurrent reader can ever observe a\n * half-written file at `path` — unlike creating `path` itself with `wx` and writing to it afterwards, which\n * leaves a window (between file creation and the write completing) where a concurrent `get()`/`add()` can read\n * an empty or truncated file and throw a JSON parse error instead of losing the race cleanly.\n *\n * If the key holds an expired or corrupt entry, the takeover happens under a per-key mutex (see\n * takeOverExpired), so two callers can never both replace it.\n */\n async add(key: string, value: unknown, seconds?: number): Promise<boolean> {\n const path = this.path(key)\n const expiresAt = seconds === undefined ? FOREVER : now() + seconds * 1000\n const temp = await this.writeTemp(path, this.encode(value, expiresAt))\n try {\n if (await this.linkExclusive(temp, path)) return true\n if (isLive(await this.readPayload(path))) return false\n return await this.takeOverExpired(path, temp)\n } finally {\n await rm(temp, { force: true })\n }\n }\n\n private async linkExclusive(from: string, to: string): Promise<boolean> {\n try {\n await link(from, to)\n return true\n } catch (error) {\n if (errorCode(error) === 'EEXIST') return false\n throw error\n }\n }\n\n /**\n * Replaces an expired or corrupt entry, holding `path + '.lock'` (created with the same link() trick) so only\n * one add() at a time can take it over. A caller that finds the mutex held loses without waiting: the holder\n * is replacing the entry right now, so at that moment the key is taken either way. Inside the mutex the entry\n * is re-read (it may have been replaced by a put() meanwhile), then removed and our file linked in: if anything\n * else creates the key in between (a put(), or an add() after a forget()), the link fails and we lose cleanly.\n */\n private async takeOverExpired(path: string, temp: string): Promise<boolean> {\n const mutex = `${path}.lock`\n const token = await this.acquireMutex(mutex)\n if (token === undefined) return false\n try {\n if (isLive(await this.readPayload(path))) return false\n await rm(path, { force: true })\n return await this.linkExclusive(temp, path)\n } finally {\n await this.releaseMutex(mutex, token)\n }\n }\n\n /** Returns our token once the mutex is held, or undefined if another live holder has it. */\n private async acquireMutex(mutex: string, retried = false): Promise<string | undefined> {\n const token = `${process.pid}-${Math.random().toString(36).slice(2)}`\n const temp = await this.writeTemp(mutex, token)\n try {\n if (await this.linkExclusive(temp, mutex)) return token\n } finally {\n await rm(temp, { force: true })\n }\n if (retried) return undefined\n let modified: number\n try {\n modified = (await stat(mutex)).mtimeMs\n } catch (error) {\n if (errorCode(error) === 'ENOENT') return this.acquireMutex(mutex, true) // released meanwhile\n throw error\n }\n if (now() - modified < MUTEX_STALE_MS) return undefined\n // Its holder crashed: clear it and try once more.\n await rm(mutex, { force: true })\n return this.acquireMutex(mutex, true)\n }\n\n /** Only removes the mutex if it is still ours (a stalled holder's mutex may have been cleared as stale). */\n private async releaseMutex(mutex: string, token: string): Promise<void> {\n try {\n if ((await readFile(mutex, 'utf8')) === token) await rm(mutex, { force: true })\n } catch (error) {\n if (errorCode(error) !== 'ENOENT') throw error\n }\n }\n\n async increment(key: string, by: number): Promise<number> {\n const path = this.path(key)\n const payload = await this.readPayload(path)\n const existing = isLive(payload) ? payload : undefined\n const current = existing && typeof existing.value === 'number' ? existing.value : 0\n const next = current + by\n await this.atomicWrite(path, this.encode(next, existing?.expiresAt ?? FOREVER))\n return next\n }\n\n decrement(key: string, by: number): Promise<number> {\n return this.increment(key, -by)\n }\n\n async forget(key: string): Promise<boolean> {\n try {\n await rm(this.path(key))\n return true\n } catch (error) {\n if (errorCode(error) === 'ENOENT') return false\n throw error\n }\n }\n\n /** Clears the whole directory, regardless of prefix — matches Laravel's FileStore::flush(). */\n async flush(): Promise<boolean> {\n await rm(this.directory, { recursive: true, force: true })\n await mkdir(this.directory, { recursive: true })\n return true\n }\n}\n","import type { DatabaseConnection } from '@orieljs/contracts'\n\n/**\n * Laravel's add()/acquire(): insert the row unless its key exists, and otherwise take the row over only when it has\n * expired. Returns whether the row is now this caller's. `row` holds the `key` and `expiration` columns.\n *\n * The insert never fails on a taken key (insertOrIgnore), so it can't abort the caller's transaction on Postgres and\n * needs no savepoint or queue: concurrent callers, in one transaction or in several, only wait on the database's own\n * row locks.\n */\nexport async function insertOrTakeOver(connection: DatabaseConnection, table: string, row: Record<string, unknown>): Promise<boolean> {\n if ((await connection.table(table).insertOrIgnore(row)) === 1) return true\n const now = Math.floor(Date.now() / 1000)\n return (await connection.table(table).where('key', row.key).where('expiration', '<=', now).update(row)) > 0\n}\n","import type { DatabaseConnection, QueryBuilder } from '@orieljs/contracts'\nimport { insertOrTakeOver } from '../insertOrTakeOver'\nimport { deserialize, roundTrip, serialize } from '../serialize'\nimport type { Store } from '../Store'\n\n/**\n * \"Forever\" here is a 10-year TTL from now, not a fixed epoch sentinel: `expiration` is an `integer` column\n * (Postgres/MySQL `int4`, max 2147483647), and the epoch-millisecond sentinel FileStore uses (9999999999999) overflows\n * it. This is Laravel's own DatabaseStore::forever(), which calls `put(key, value, 315360000)` for the same\n * reason, rather than a magic-number timestamp.\n */\nconst FOREVER_SECONDS = 315360000\n\ninterface CacheRow {\n key: string\n value: string\n expiration: number\n}\n\nconst now = (): number => Math.floor(Date.now() / 1000)\n\n/** Store impl over the `cache` table, resolved through DatabaseManager (never imports @orieljs/database). */\nexport class DatabaseStore implements Store {\n constructor(\n private readonly connection: DatabaseConnection,\n private readonly table: string,\n private readonly keyPrefix: string = '',\n ) {}\n\n private k(key: string): string {\n return this.keyPrefix + key\n }\n\n async get(key: string): Promise<unknown> {\n const k = this.k(key)\n const row = await this.connection.table<CacheRow>(this.table).where('key', k).first()\n if (!row) return undefined\n if (row.expiration <= now()) {\n // Only delete while still expired: another process may have rewritten the key since we read it.\n await this.connection.table(this.table).where('key', k).where('expiration', '<=', now()).delete()\n return undefined\n }\n return deserialize(row.value)\n }\n\n async many(keys: string[]): Promise<Record<string, unknown>> {\n if (keys.length === 0) return {}\n const prefixed = keys.map((key) => this.k(key))\n const rows = await this.connection.table<CacheRow>(this.table).whereIn('key', prefixed).get()\n const byKey = new Map(rows.all().map((row) => [row.key, row]))\n const time = now()\n const result: Record<string, unknown> = {}\n keys.forEach((key, i) => {\n const row = byKey.get(prefixed[i]!)\n if (row && row.expiration > time) result[key] = deserialize(row.value)\n })\n return result\n }\n\n async put(key: string, value: unknown, seconds: number): Promise<boolean> {\n return this.write(this.k(key), value, now() + Math.ceil(seconds))\n }\n\n async putForever(key: string, value: unknown): Promise<boolean> {\n return this.write(this.k(key), value, now() + FOREVER_SECONDS)\n }\n\n private async write(key: string, value: unknown, expiration: number): Promise<boolean> {\n await this.connection.table(this.table).upsert({ key, value: serialize(roundTrip(value)), expiration }, ['key'])\n return true\n }\n\n /**\n * Laravel's DatabaseStore::add(): an insert that skips a taken key, and then a conditional update that only takes\n * over an expired row (see insertOrTakeOver). Nothing fails on a taken key, so a caller's transaction stays usable.\n */\n async add(key: string, value: unknown, seconds?: number): Promise<boolean> {\n const k = this.k(key)\n const expiration = seconds === undefined ? now() + FOREVER_SECONDS : now() + Math.ceil(seconds)\n const row = { key: k, value: serialize(roundTrip(value)), expiration }\n return insertOrTakeOver(this.connection, this.table, row)\n }\n\n async increment(key: string, by: number, attempt = 0): Promise<number> {\n const k = this.k(key)\n try {\n return await this.connection.transaction(async (trx) => {\n const existing = await trx.table<CacheRow>(this.table).where('key', k).lockForUpdate().first()\n const unexpired = existing !== undefined && existing.expiration > now()\n const current = unexpired ? Number(deserialize(existing!.value)) : 0\n const next = current + by\n const expiration = unexpired ? existing!.expiration : now() + FOREVER_SECONDS\n const row = { key: k, value: serialize(next), expiration }\n if (existing) await trx.table(this.table).where('key', k).update(row)\n else await trx.table(this.table).insert(row)\n return next\n })\n } catch (error) {\n // Another writer's increment()/put() inserted this key between our lockForUpdate read (which saw no row)\n // and our own insert. Unlike add(), we can't just leave the other\n // writer's value alone — Store.ts requires increment() to apply `by` on top of whatever is there — so\n // retry the whole transaction once, this time reading the row the other writer just created. A second\n // failure propagates: something other than a benign insert race is going on.\n if (attempt > 0) throw error\n return this.increment(key, by, attempt + 1)\n }\n }\n\n decrement(key: string, by: number): Promise<number> {\n return this.increment(key, -by)\n }\n\n async forget(key: string): Promise<boolean> {\n const deleted = await this.connection.table(this.table).where('key', this.k(key)).delete()\n return deleted > 0\n }\n\n /**\n * Deletes this store's keys: those starting with its prefix (every row without one). The prefix's `%` and `_` are\n * escaped, so another app's keys in the same table, `appXcache_…` beside `app_cache_…`, stay.\n */\n async flush(): Promise<boolean> {\n if (!this.keyPrefix) {\n await this.connection.table(this.table).delete()\n return true\n }\n // `!` escapes the same way on every driver (SQLite has no default LIKE escape); `key` is reserved in MySQL.\n const column = this.connection.getDriverName() === 'mysql' ? '`key`' : '\"key\"'\n const pattern = `${this.keyPrefix.replace(/[!%_]/g, (character) => `!${character}`)}%`\n // The contract's builder has no whereRaw(); Oriel's own builder, which every connection's table() returns, does.\n const query = this.connection.table(this.table) as QueryBuilder & { whereRaw(sql: string, bindings: readonly unknown[]): QueryBuilder }\n await query.whereRaw(`${column} like ? escape '!'`, [pattern]).delete()\n return true\n }\n}\n","import { setTimeout as sleep } from 'node:timers/promises'\nimport type { DatabaseConnection, Lock } from '@orieljs/contracts'\nimport { Str } from '@orieljs/support'\nimport { LockTimeoutError } from '../errors'\nimport { insertOrTakeOver } from '../insertOrTakeOver'\n\n// See DatabaseStore.ts: a 10-year TTL from now, not an epoch sentinel — `expiration` is an `integer` column and\n// FileStore's 9999999999999 sentinel overflows it on Postgres/MySQL (B8). Matches Laravel's DatabaseStore/DatabaseLock.\nconst FOREVER_SECONDS = 315360000\nconst now = (): number => Math.floor(Date.now() / 1000)\n\ninterface LockRow {\n key: string\n owner: string\n expiration: number\n}\n\n/**\n * Locks use their own `cache_locks` table (not `cache`), like Laravel's DatabaseLock: a `value` column with\n * arbitrary serialized data would make comparing owners awkward, so locks get dedicated `owner`/`expiration`\n * columns instead.\n */\nexport class DatabaseLock implements Lock {\n private readonly ownerValue: string\n\n constructor(\n private readonly connection: DatabaseConnection,\n private readonly table: string,\n private readonly name: string,\n private readonly seconds: number | undefined,\n owner?: string,\n private readonly pollMs = 50,\n ) {\n this.ownerValue = owner ?? Str.random(20)\n }\n\n owner(): string {\n return this.ownerValue\n }\n\n async get<T = boolean>(callback?: () => T | Promise<T>): Promise<T | false> {\n const acquired = await this.acquire()\n if (!acquired) return false\n if (!callback) return true as T\n try {\n return await callback()\n } finally {\n await this.release()\n }\n }\n\n async block<T = boolean>(seconds: number, callback?: () => T | Promise<T>): Promise<T | true> {\n const deadline = Date.now() + seconds * 1000\n for (;;) {\n if (await this.acquire()) break\n if (Date.now() >= deadline) throw new LockTimeoutError(this.name)\n await sleep(this.pollMs)\n }\n if (!callback) return true\n try {\n return await callback()\n } finally {\n await this.release()\n }\n }\n\n async release(): Promise<boolean> {\n return this.connection.transaction(async (trx) => {\n const existing = await trx.table<LockRow>(this.table).where('key', this.name).lockForUpdate().first()\n if (!existing || existing.owner !== this.ownerValue) return false\n await trx.table(this.table).where('key', this.name).delete()\n return true\n })\n }\n\n async forceRelease(): Promise<void> {\n await this.connection.table(this.table).where('key', this.name).delete()\n }\n\n /**\n * Laravel's DatabaseLock::acquire(): an insert that skips a taken key, and then a conditional update that only takes\n * over an expired lock (no re-entry for the same owner, like RedisLock); see insertOrTakeOver.\n */\n private async acquire(): Promise<boolean> {\n const expiration = this.seconds === undefined ? now() + FOREVER_SECONDS : now() + Math.ceil(this.seconds)\n const row = { key: this.name, owner: this.ownerValue, expiration }\n return insertOrTakeOver(this.connection, this.table, row)\n }\n}\n","/**\n * Text for `database/migrations/..._create_cache_table.ts`. Cache does not own migrations — Database does — so\n * this is plain text for the coordinator's Wave-1 C2 skeleton step to copy in, not code Cache compiles against.\n * Mirrors Laravel 11's default cache migration: one file, two tables. `expiration` stays a plain `integer`\n * (int4/int, max 2147483647): DatabaseStore/DatabaseLock's \"forever\" is a 10-year TTL from now\n * (`FOREVER_SECONDS`), never a fixed epoch sentinel, so it always fits (B8).\n */\nexport const CACHE_TABLE_MIGRATION = `import { Migration, Schema } from '@orieljs/framework'\n\nexport default class extends Migration {\n async up() {\n await Schema.create('cache', (t) => {\n t.string('key').primary()\n t.text('value')\n t.integer('expiration')\n })\n await Schema.create('cache_locks', (t) => {\n t.string('key').primary()\n t.string('owner')\n t.integer('expiration')\n })\n }\n\n async down() {\n await Schema.dropIfExists('cache_locks')\n await Schema.dropIfExists('cache')\n }\n}\n`\n","import { createHash, randomUUID } from 'node:crypto'\nimport type { Redis } from 'ioredis'\nimport { importOptional } from '@orieljs/support'\nimport { deserialize, roundTrip, serialize } from '../serialize'\nimport type { Store } from '../Store'\n\nexport interface RedisConfig {\n /** A prebuilt ioredis instance. A string here (Laravel's `'client' => 'phpredis'` style) is ignored. */\n client?: Redis | string\n url?: string\n [option: string]: unknown\n}\n\n/**\n * Builds an ioredis client from cache.stores.redis config: a prebuilt client, or a URL and/or raw ioredis\n * options. With a URL, the remaining options (db, password, lazyConnect...) are still passed through. ioredis is an\n * optional package, imported here, the first time a store needs a client: without it, this throws\n * MissingPackageError, saying to install it. A prebuilt client imports nothing.\n */\nexport async function makeRedisClient(config: RedisConfig): Promise<Redis> {\n if (typeof config.client === 'object' && config.client !== null) return config.client\n const { Redis } = await importOptional('ioredis', 'The redis cache store', () => import('ioredis'))\n const { client: _client, url, driver: _driver, prefix: _prefix, connection: _connection, ...options } = config\n if (typeof url === 'string') return new Redis(url, options)\n return new Redis(options)\n}\n\n/**\n * A store's client: one given, or one made at first use (and kept), so ioredis is only imported when it's needed. A\n * client given is there from the start, so the app's shutdown quits it as soon as its store is built.\n */\nexport class RedisConnection {\n #client: Promise<Redis> | undefined\n\n constructor(private readonly source: Redis | (() => Promise<Redis>)) {\n if (typeof source !== 'function') this.#client = Promise.resolve(source)\n }\n\n client(): Promise<Redis> {\n return (this.#client ??= (this.source as () => Promise<Redis>)())\n }\n\n /** Whether there's a client: one given, or one made for a command. A store that has neither has nothing to close. */\n started(): boolean {\n return this.#client !== undefined\n }\n}\n\nconst connectionOf = (redis: Redis | RedisConnection | (() => Promise<Redis>)): RedisConnection =>\n redis instanceof RedisConnection ? redis : new RedisConnection(redis)\n\n/** Shared low-level redis primitives, parameterized only by the fully-computed key. No prefixing here on purpose:\n * RedisStore and RedisTaggedStore each compute their own keys and never rely on ioredis's `keyPrefix` client\n * option (which doesn't rewrite SCAN's MATCH pattern, making prefixed flush()/tag-namespace lookups unreliable). */\nabstract class RedisPrimitives {\n protected readonly connection: RedisConnection\n\n protected constructor(redis: Redis | RedisConnection | (() => Promise<Redis>)) {\n this.connection = connectionOf(redis)\n }\n\n /** The client, made at the first command. */\n protected redis(): Promise<Redis> {\n return this.connection.client()\n }\n\n getConnection(): RedisConnection {\n return this.connection\n }\n\n protected async rawGet(key: string): Promise<unknown> {\n const raw = await (await this.redis()).get(key)\n return raw === null ? undefined : deserialize(raw)\n }\n\n protected async rawMany(keys: string[]): Promise<Record<string, unknown>> {\n if (keys.length === 0) return {}\n const values = await (await this.redis()).mget(...keys)\n const result: Record<string, unknown> = {}\n keys.forEach((key, i) => {\n const raw = values[i]\n if (raw !== null && raw !== undefined) result[key] = deserialize(raw)\n })\n return result\n }\n\n protected async rawPut(key: string, value: unknown, ms?: number): Promise<boolean> {\n const redis = await this.redis()\n if (ms === undefined) await redis.set(key, serialize(roundTrip(value)))\n else await redis.set(key, serialize(roundTrip(value)), 'PX', Math.max(1, Math.round(ms)))\n return true\n }\n\n protected async rawAdd(key: string, value: unknown, ms?: number): Promise<boolean> {\n const redis = await this.redis()\n const result =\n ms === undefined\n ? await redis.set(key, serialize(roundTrip(value)), 'NX')\n : await redis.set(key, serialize(roundTrip(value)), 'PX', Math.max(1, Math.round(ms)), 'NX')\n return result === 'OK'\n }\n\n protected async rawIncrement(key: string, by: number): Promise<number> {\n return (await this.redis()).incrby(key, by)\n }\n\n protected async rawForget(key: string): Promise<boolean> {\n return (await (await this.redis()).del(key)) > 0\n }\n}\n\nexport class RedisStore extends RedisPrimitives implements Store {\n constructor(\n redis: Redis | RedisConnection | (() => Promise<Redis>),\n private readonly keyPrefix: string = '',\n ) {\n super(redis)\n }\n\n private k(key: string): string {\n return this.keyPrefix + key\n }\n\n getPrefix(): string {\n return this.keyPrefix\n }\n\n get(key: string): Promise<unknown> {\n return this.rawGet(this.k(key))\n }\n\n async many(keys: string[]): Promise<Record<string, unknown>> {\n const prefixed = keys.map((key) => this.k(key))\n const found = await this.rawMany(prefixed)\n const result: Record<string, unknown> = {}\n keys.forEach((key, i) => {\n const p = prefixed[i]!\n if (p in found) result[key] = found[p]\n })\n return result\n }\n\n put(key: string, value: unknown, seconds: number): Promise<boolean> {\n return this.rawPut(this.k(key), value, seconds * 1000)\n }\n\n putForever(key: string, value: unknown): Promise<boolean> {\n return this.rawPut(this.k(key), value)\n }\n\n add(key: string, value: unknown, seconds?: number): Promise<boolean> {\n return this.rawAdd(this.k(key), value, seconds === undefined ? undefined : seconds * 1000)\n }\n\n increment(key: string, by: number): Promise<number> {\n return this.rawIncrement(this.k(key), by)\n }\n\n decrement(key: string, by: number): Promise<number> {\n return this.rawIncrement(this.k(key), -by)\n }\n\n forget(key: string): Promise<boolean> {\n return this.rawForget(this.k(key))\n }\n\n async flush(): Promise<boolean> {\n const redis = await this.redis()\n let cursor = '0'\n do {\n const [next, keys] = await redis.scan(cursor, 'MATCH', `${this.keyPrefix}*`, 'COUNT', 200)\n cursor = next\n if (keys.length > 0) await redis.unlink(...keys)\n } while (cursor !== '0')\n return true\n }\n\n tags(names: string[]): RedisTaggedStore {\n return new RedisTaggedStore(this.connection, this.keyPrefix, names)\n }\n}\n\n/**\n * A namespaced view of the same redis database. Every tag has a version (a random id); the namespace is a hash\n * of the sorted tag=version pairs. flush() bumps every tag's version, orphaning previously-namespaced entries\n * (they aren't deleted — they expire on their own TTL) — this is Laravel's actual TagSet::reset() behaviour.\n */\nexport class RedisTaggedStore extends RedisPrimitives implements Store {\n constructor(\n redis: Redis | RedisConnection | (() => Promise<Redis>),\n private readonly keyPrefix: string,\n private readonly tagNames: string[],\n ) {\n super(redis)\n }\n\n private async tagVersion(name: string): Promise<string> {\n const key = `${this.keyPrefix}tag:${name}:version`\n const redis = await this.redis()\n const existing = await redis.get(key)\n if (existing !== null) return existing\n const version = randomUUID()\n const set = await redis.set(key, version, 'NX')\n return set === 'OK' ? version : ((await redis.get(key)) ?? version)\n }\n\n private async namespace(): Promise<string> {\n const versions = await Promise.all(this.tagNames.map((name) => this.tagVersion(name)))\n const joined = this.tagNames.map((name, i) => `${name}=${versions[i]}`).sort().join('|')\n return createHash('sha1').update(joined).digest('hex').slice(0, 16)\n }\n\n private async k(key: string): Promise<string> {\n return `${this.keyPrefix}tags:${await this.namespace()}:${key}`\n }\n\n async get(key: string): Promise<unknown> {\n return this.rawGet(await this.k(key))\n }\n\n async many(keys: string[]): Promise<Record<string, unknown>> {\n const prefixed = await Promise.all(keys.map((key) => this.k(key)))\n const found = await this.rawMany(prefixed)\n const result: Record<string, unknown> = {}\n keys.forEach((key, i) => {\n const p = prefixed[i]!\n if (p in found) result[key] = found[p]\n })\n return result\n }\n\n async put(key: string, value: unknown, seconds: number): Promise<boolean> {\n return this.rawPut(await this.k(key), value, seconds * 1000)\n }\n\n async putForever(key: string, value: unknown): Promise<boolean> {\n return this.rawPut(await this.k(key), value)\n }\n\n async add(key: string, value: unknown, seconds?: number): Promise<boolean> {\n return this.rawAdd(await this.k(key), value, seconds === undefined ? undefined : seconds * 1000)\n }\n\n async increment(key: string, by: number): Promise<number> {\n return this.rawIncrement(await this.k(key), by)\n }\n\n async decrement(key: string, by: number): Promise<number> {\n return this.rawIncrement(await this.k(key), -by)\n }\n\n async forget(key: string): Promise<boolean> {\n return this.rawForget(await this.k(key))\n }\n\n async flush(): Promise<boolean> {\n const redis = await this.redis()\n await Promise.all(this.tagNames.map((name) => redis.set(`${this.keyPrefix}tag:${name}:version`, randomUUID())))\n return true\n }\n}\n","import { setTimeout as sleep } from 'node:timers/promises'\nimport type { Lock } from '@orieljs/contracts'\nimport type { Redis } from 'ioredis'\nimport { Str } from '@orieljs/support'\nimport { LockTimeoutError } from '../errors'\nimport { RedisConnection } from '../stores/RedisStore'\n\nconst RELEASE_SCRIPT = 'if redis.call(\"get\", KEYS[1]) == ARGV[1] then return redis.call(\"del\", KEYS[1]) else return 0 end'\n\n/** SET key value [PX ms] NX to acquire; a Lua script to release only if we still own it (compare-and-delete). */\nexport class RedisLock implements Lock {\n private readonly ownerValue: string\n private readonly connection: RedisConnection\n\n /** `redis` is a client, or a store's connection (whose client is made at first use). */\n constructor(\n redis: Redis | RedisConnection,\n private readonly name: string,\n private readonly seconds: number | undefined,\n owner?: string,\n private readonly pollMs = 50,\n ) {\n this.ownerValue = owner ?? Str.random(20)\n this.connection = redis instanceof RedisConnection ? redis : new RedisConnection(redis)\n }\n\n owner(): string {\n return this.ownerValue\n }\n\n async get<T = boolean>(callback?: () => T | Promise<T>): Promise<T | false> {\n const acquired = await this.acquire()\n if (!acquired) return false\n if (!callback) return true as T\n try {\n return await callback()\n } finally {\n await this.release()\n }\n }\n\n async block<T = boolean>(seconds: number, callback?: () => T | Promise<T>): Promise<T | true> {\n const deadline = Date.now() + seconds * 1000\n for (;;) {\n if (await this.acquire()) break\n if (Date.now() >= deadline) throw new LockTimeoutError(this.name)\n await sleep(this.pollMs)\n }\n if (!callback) return true\n try {\n return await callback()\n } finally {\n await this.release()\n }\n }\n\n async release(): Promise<boolean> {\n const result = await (await this.connection.client()).eval(RELEASE_SCRIPT, 1, this.name, this.ownerValue)\n return result === 1\n }\n\n async forceRelease(): Promise<void> {\n await (await this.connection.client()).del(this.name)\n }\n\n private async acquire(): Promise<boolean> {\n const redis = await this.connection.client()\n const result =\n this.seconds === undefined\n ? await redis.set(this.name, this.ownerValue, 'NX')\n : await redis.set(this.name, this.ownerValue, 'PX', Math.max(1, Math.round(this.seconds * 1000)), 'NX')\n return result === 'OK'\n }\n}\n","import type { CacheRepository } from '@orieljs/contracts'\nimport type { Redis } from 'ioredis'\nimport { RedisLock } from '../locks/RedisLock'\nimport { Repository } from '../Repository'\nimport { RedisStore } from './RedisStore'\n\n/** Each client's QUIT, from the first store that sends it until the connection has closed. */\nconst quitting = new WeakMap<Redis, Promise<void>>()\n\n/** The only Repository subclass: the only store where tags() doesn't throw. */\nexport class RedisRepository extends Repository {\n constructor(private readonly redisStore: RedisStore) {\n // Lock keys carry the store's prefix, like every cache key (and like Laravel's RedisStore::lock()).\n super(redisStore, (_store, name, seconds, owner) => new RedisLock(redisStore.getConnection(), redisStore.getPrefix() + name, seconds, owner))\n }\n\n /**\n * Closes the redis client (CacheManager.disconnectAll() at shutdown): a connected one with QUIT, one that never\n * connected or is reconnecting without waiting; one already closed is left alone. A client two stores share is quit\n * once: QUIT resolves on the server's reply, but the client reads 'ready' until its socket closes, so the second\n * store waits on the first one's QUIT instead of sending another (which would fail with \"Connection is closed.\").\n * A store that never made its client has nothing to close.\n */\n async disconnect(): Promise<void> {\n const connection = this.redisStore.getConnection()\n if (!connection.started()) return\n const redis = await connection.client().catch(() => undefined)\n if (redis === undefined) return\n const pending = quitting.get(redis)\n if (pending) return pending\n if (redis.status === 'end') return\n if (redis.status !== 'ready') return redis.disconnect()\n const quit = redis.quit().then(() => undefined)\n quitting.set(redis, quit)\n // Forgotten once closed, so a client connected again later is quit again.\n redis.once('end', () => quitting.delete(redis))\n return quit\n }\n\n override tags(names: string | string[]): CacheRepository {\n const list = Array.isArray(names) ? names : [names]\n const taggedStore = this.redisStore.tags(list)\n // Tagged locks use the same base prefix: tags namespace entries, not locks.\n const prefix = this.redisStore.getPrefix()\n return new Repository(taggedStore, (_store, name, seconds, owner) => new RedisLock(this.redisStore.getConnection(), prefix + name, seconds, owner))\n }\n}\n","import type { CacheRepository, Container } from '@orieljs/contracts'\nimport { CacheManager as CacheManagerToken, ConfigRepository, DatabaseManager } from '@orieljs/contracts'\nimport { UnknownCacheDriverError, UnknownCacheStoreError } from './errors'\nimport { DatabaseLock } from './locks/DatabaseLock'\nimport { Repository } from './Repository'\nimport { DatabaseStore } from './stores/DatabaseStore'\nimport { FileStore } from './stores/FileStore'\nimport { MemoryStore } from './stores/MemoryStore'\nimport type { Redis } from 'ioredis'\nimport { makeRedisClient, RedisStore } from './stores/RedisStore'\nimport { RedisRepository } from './stores/RedisRepository'\n\ntype StoreConfig = Record<string, unknown>\ntype Driver = (config: StoreConfig) => CacheRepository\n\n/**\n * Resolves the ioredis config for the `redis` cache driver, as a pure function so the fallback logic is testable\n * without a real redis connection. An inline `url` or client instance on `cache.stores.redis` wins and is passed straight\n * through; otherwise this falls back to `database.redis.<connection ?? 'default'>` (U3, Laravel's own\n * convention) — Session and Queue's redis connections resolve the exact same way, so one `database.redis`\n * config block covers every component that needs redis.\n */\nexport function resolveRedisConfig(cfg: StoreConfig, lookupDatabaseRedis: (connectionName: string) => StoreConfig): StoreConfig {\n const hasClient = typeof cfg.client === 'object' && cfg.client !== null\n if (cfg.url !== undefined || hasClient) return cfg\n const connectionName = (cfg.connection as string | undefined) ?? 'default'\n return { ...lookupDatabaseRedis(connectionName), ...cfg }\n}\n\ninterface CacheConfig {\n default: string\n prefix?: string\n stores: Record<string, StoreConfig>\n}\n\nexport class CacheManager implements CacheManagerToken {\n private readonly stores = new Map<string, CacheRepository>()\n private readonly drivers = new Map<string, Driver>()\n\n constructor(private readonly container: Container) {\n this.drivers.set('memory', (cfg) => new Repository(new MemoryStore(this.str(cfg.prefix), cfg.maxItems as number | undefined)))\n this.drivers.set('array', (cfg) => new Repository(new MemoryStore(this.str(cfg.prefix))))\n this.drivers.set('file', (cfg) => new Repository(new FileStore(cfg.path as string, this.str(cfg.prefix))))\n this.drivers.set('database', (cfg) => this.buildDatabaseStore(cfg))\n this.drivers.set('redis', (cfg) => this.buildRedisStore(cfg))\n }\n\n private str(value: unknown): string {\n return typeof value === 'string' ? value : ''\n }\n\n private cacheConfig(): CacheConfig {\n return this.container.make(ConfigRepository).get<CacheConfig>('cache', { default: 'database', stores: {} })\n }\n\n private buildDatabaseStore(cfg: StoreConfig): CacheRepository {\n const connection = this.container.make(DatabaseManager).connection(cfg.connection as string | undefined)\n const table = (cfg.table as string | undefined) ?? 'cache'\n const lockTable = (cfg.lockTable as string | undefined) ?? 'cache_locks'\n const prefix = this.str(cfg.prefix)\n const store = new DatabaseStore(connection, table, prefix)\n // Lock names carry the store's prefix, like every cache key (and like Laravel's DatabaseStore::lock()).\n return new Repository(store, (_store, name, seconds, owner) => new DatabaseLock(connection, lockTable, prefix + name, seconds, owner))\n }\n\n private buildRedisStore(cfg: StoreConfig): CacheRepository {\n const resolved = resolveRedisConfig(cfg, (connectionName) =>\n this.container.make(ConfigRepository).get<StoreConfig>(`database.redis.${connectionName}`, {}),\n )\n // A prebuilt client is used as it is; any other is made at the store's first command, so ioredis is only imported\n // by an app that uses it.\n const client = typeof resolved.client === 'object' && resolved.client !== null ? (resolved.client as Redis) : undefined\n const store = new RedisStore(client ?? (() => makeRedisClient(resolved)), this.str(cfg.prefix))\n return new RedisRepository(store)\n }\n\n store(name?: string): CacheRepository {\n const cacheConfig = this.cacheConfig()\n const storeName = name ?? cacheConfig.default\n let repository = this.stores.get(storeName)\n if (!repository) {\n const storeConfig = cacheConfig.stores[storeName]\n if (!storeConfig) throw new UnknownCacheStoreError(storeName)\n const driverName = storeConfig.driver as string | undefined\n const driver = driverName ? this.drivers.get(driverName) : undefined\n if (!driver) throw new UnknownCacheDriverError(String(driverName))\n repository = driver({ ...storeConfig, prefix: storeConfig.prefix ?? cacheConfig.prefix ?? '' })\n this.stores.set(storeName, repository)\n }\n return repository\n }\n\n /**\n * Closes the redis clients of the stores resolved so far and forgets the stores, so the next use builds them again\n * (the app's shutdown calls it). Stores without a connection to close are only forgotten. A store that fails to\n * close doesn't keep the others open: all are closed, then its error is thrown (several: an AggregateError).\n */\n async disconnectAll(): Promise<void> {\n const stores = [...this.stores.values()]\n this.stores.clear()\n const results = await Promise.allSettled(\n stores.map(async (store) => (store as CacheRepository & { disconnect?(): Promise<void> }).disconnect?.()),\n )\n // A set: two stores sharing a client whose QUIT failed report that one error once.\n const errors = [...new Set(results.flatMap((result) => (result.status === 'rejected' ? [result.reason as unknown] : [])))]\n if (errors.length === 1) throw errors[0]\n if (errors.length > 1) throw new AggregateError(errors, `${errors.length} cache stores failed to close.`)\n }\n\n extend(driver: string, factory: Driver): void {\n this.drivers.set(driver, factory)\n }\n\n get<T = unknown>(key: string, defaultValue?: T | (() => T)): Promise<T | undefined> {\n return defaultValue === undefined ? this.store().get<T>(key) : this.store().get<T>(key, defaultValue)\n }\n many<T = unknown>(keys: string[]): Promise<Record<string, T | undefined>> {\n return this.store().many<T>(keys)\n }\n has(key: string): Promise<boolean> {\n return this.store().has(key)\n }\n missing(key: string): Promise<boolean> {\n return this.store().missing(key)\n }\n put(key: string, value: unknown, ttlSeconds?: number): Promise<boolean> {\n return this.store().put(key, value, ttlSeconds)\n }\n add(key: string, value: unknown, ttlSeconds?: number): Promise<boolean> {\n return this.store().add(key, value, ttlSeconds)\n }\n increment(key: string, by?: number): Promise<number> {\n return this.store().increment(key, by)\n }\n decrement(key: string, by?: number): Promise<number> {\n return this.store().decrement(key, by)\n }\n forever(key: string, value: unknown): Promise<boolean> {\n return this.store().forever(key, value)\n }\n pull<T = unknown>(key: string, defaultValue?: T): Promise<T | undefined> {\n return this.store().pull<T>(key, defaultValue)\n }\n forget(key: string): Promise<boolean> {\n return this.store().forget(key)\n }\n flush(): Promise<boolean> {\n return this.store().flush()\n }\n remember<T>(key: string, ttlSeconds: number, callback: () => T | Promise<T>): Promise<T> {\n return this.store().remember(key, ttlSeconds, callback)\n }\n rememberForever<T>(key: string, callback: () => T | Promise<T>): Promise<T> {\n return this.store().rememberForever(key, callback)\n }\n lock(name: string, seconds?: number, owner?: string) {\n return this.store().lock(name, seconds, owner)\n }\n tags(names: string | string[]): CacheRepository {\n return this.store().tags(names)\n }\n}\n","import type { CacheRepository, RateLimiter, RateLimiterCallback } from '@orieljs/contracts'\n\nconst now = (): number => Math.floor(Date.now() / 1000)\n\n/**\n * Laravel's Illuminate\\Cache\\RateLimiter over a cache store: `<key>` holds the hit count and `<key>:timer` the unix\n * time the window ends, both expiring with the window. The store is resolved on every call, so a store swapped in\n * a test (or config changed at run time) is the one used.\n */\nexport class CacheRateLimiter implements RateLimiter {\n readonly #limiters = new Map<string, RateLimiterCallback>()\n\n constructor(private readonly store: () => CacheRepository) {}\n\n /** Laravel's RateLimiter::for(): names a limiter that `throttle:<name>` uses. */\n for(name: string, callback: RateLimiterCallback): void {\n this.#limiters.set(name, callback)\n }\n\n limiter(name: string): RateLimiterCallback | undefined {\n return this.#limiters.get(name)\n }\n\n /** Laravel's attempt(): false when `key` is out of attempts; else the callback's result (true for nothing), and a hit. */\n async attempt<T>(key: string, maxAttempts: number, callback: () => T | Promise<T>, decaySeconds = 60): Promise<T | boolean> {\n if (await this.tooManyAttempts(key, maxAttempts)) return false\n const result = await callback()\n await this.hit(key, decaySeconds)\n return result === undefined || result === null ? true : result\n }\n\n async tooManyAttempts(key: string, maxAttempts: number): Promise<boolean> {\n const clean = this.cleanKey(key)\n if ((await this.#attempts(clean)) >= maxAttempts) {\n if (await this.store().has(`${clean}:timer`)) return true\n await this.store().forget(clean)\n }\n return false\n }\n\n async hit(key: string, decaySeconds = 60): Promise<number> {\n const clean = this.cleanKey(key)\n const cache = this.store()\n await cache.add(`${clean}:timer`, now() + decaySeconds, decaySeconds)\n const added = await cache.add(clean, 0, decaySeconds)\n const hits = await cache.increment(clean)\n // The count expired between add() and increment(), which then stored it forever: give it the window again.\n if (!added && hits === 1) await cache.put(clean, 1, decaySeconds)\n return hits\n }\n\n attempts(key: string): Promise<number> {\n return this.#attempts(this.cleanKey(key))\n }\n\n async remaining(key: string, maxAttempts: number): Promise<number> {\n return Math.max(0, maxAttempts - (await this.#attempts(this.cleanKey(key))))\n }\n\n async availableIn(key: string): Promise<number> {\n const timer = await this.store().get<number>(`${this.cleanKey(key)}:timer`)\n return timer === undefined ? 0 : Math.max(0, Number(timer) - now())\n }\n\n async clear(key: string): Promise<void> {\n const clean = this.cleanKey(key)\n await this.store().forget(clean)\n await this.store().forget(`${clean}:timer`)\n }\n\n /** Laravel's cleanRateLimiterKey(): accented letters become their plain letter ('zoë' and 'zoe' share a key). */\n protected cleanKey(key: string): string {\n return key.normalize('NFKD').replace(/[̀-ͯ]/g, '')\n }\n\n async #attempts(clean: string): Promise<number> {\n return Number((await this.store().get<number>(clean)) ?? 0)\n }\n}\n","import type { RateLimit } from '@orieljs/contracts'\n\n/**\n * Laravel's Limit, what a named rate limiter returns: `maxAttempts` hits per `decaySeconds`, counted per `by()` key\n * (one count for everyone without it).\n *\n * RateLimiter.for('uploads', (request) => Limit.perMinute(10).by(request.ip() ?? ''))\n */\nexport class Limit implements RateLimit {\n key = ''\n\n constructor(\n readonly maxAttempts: number,\n readonly decaySeconds: number,\n readonly unlimited = false,\n ) {}\n\n static perSecond(maxAttempts: number, decaySeconds = 1): Limit {\n return new Limit(maxAttempts, decaySeconds)\n }\n\n static perMinute(maxAttempts: number, decayMinutes = 1): Limit {\n return new Limit(maxAttempts, 60 * decayMinutes)\n }\n\n static perMinutes(decayMinutes: number, maxAttempts: number): Limit {\n return new Limit(maxAttempts, 60 * decayMinutes)\n }\n\n static perHour(maxAttempts: number, decayHours = 1): Limit {\n return new Limit(maxAttempts, 3600 * decayHours)\n }\n\n static perDay(maxAttempts: number, decayDays = 1): Limit {\n return new Limit(maxAttempts, 86400 * decayDays)\n }\n\n /** Laravel's Limit::none(): no limit, and no rate limit headers. */\n static none(): Limit {\n return new Limit(Number.MAX_SAFE_INTEGER, 60, true)\n }\n\n /** The key the hits are counted under, such as the user's id or the IP address. */\n by(key: unknown): this {\n this.key = String(key)\n return this\n }\n}\n","import type { CacheManager, RateLimiter as RateLimiterContract } from '@orieljs/contracts'\nimport { CacheManager as CacheManagerToken, RateLimiter as RateLimiterToken } from '@orieljs/contracts'\nimport { inject } from '@orieljs/container'\nimport { facade } from '@orieljs/support'\n\nexport const Cache = facade<CacheManager>(CacheManagerToken)\n\n/** The RateLimiter facade: RateLimiter.tooManyAttempts(key, 5), RateLimiter.hit(key), RateLimiter.clear(key). */\nexport const RateLimiter = facade<RateLimiterContract>(RateLimiterToken)\n\nexport function cache(): CacheManager\nexport function cache(key: string): Promise<unknown>\nexport function cache(values: Record<string, unknown>, ttlSeconds?: number): Promise<boolean>\nexport function cache(arg?: string | Record<string, unknown>, ttlSeconds?: number): unknown {\n const manager = inject(CacheManagerToken)\n if (arg === undefined) return manager\n if (typeof arg === 'string') return manager.get(arg)\n return Promise.all(Object.entries(arg).map(([key, value]) => manager.put(key, value, ttlSeconds))).then((results) =>\n results.every(Boolean),\n )\n}\n","import { CacheManager as CacheManagerToken, ConfigRepository, ConsoleKernel, RateLimiter } from '@orieljs/contracts'\nimport { ServiceProvider } from '@orieljs/support'\nimport { CacheManager } from './CacheManager'\nimport { registerCacheCommands } from './commands'\nimport { CacheRateLimiter } from './RateLimiter'\n\nexport class CacheServiceProvider extends ServiceProvider {\n override register(): void {\n this.mergeConfigFrom(\n {\n default: 'database',\n prefix: '',\n stores: {\n array: { driver: 'array' },\n memory: { driver: 'memory' },\n file: { driver: 'file', path: this.app.storagePath('framework/cache/data') },\n database: { driver: 'database', table: 'cache', lockTable: 'cache_locks' },\n // Resolved from `database.redis.cache` (its own db), not `default`: flush() scans every key under the\n // prefix, so sharing a db with Queue or Session would wipe their keys too.\n redis: { driver: 'redis', connection: 'cache' },\n },\n },\n 'cache',\n )\n this.app.singleton(CacheManagerToken, (container) => new CacheManager(container))\n // At the end of the process: quit the redis clients the stores opened (never builds a manager to do it).\n this.app.onShutdown(async () => {\n if (!this.app.resolved(CacheManagerToken)) return\n await (this.app.make(CacheManagerToken) as { disconnectAll?(): Promise<void> }).disconnectAll?.()\n })\n // Laravel: the store named by cache.limiter, else the default store.\n this.app.singleton(RateLimiter, (container) => {\n return new CacheRateLimiter(() => {\n const name = container.make(ConfigRepository).get<string | undefined>('cache.limiter', undefined)\n return container.make(CacheManagerToken).store(name === undefined || name === '' ? undefined : name)\n })\n })\n }\n\n override boot(): void {\n if (this.app.bound(ConsoleKernel)) registerCacheCommands(this.app.make(ConsoleKernel), this.app)\n }\n}\n","import { CacheManager, type Application, type CommandContext, type ConsoleKernel } from '@orieljs/contracts'\n\nconst storeName = (command: CommandContext): string | undefined => {\n const given = command.argument('store')\n return typeof given === 'string' && given !== '' ? given : undefined\n}\n\n/** Laravel's `cache:clear` and `cache:forget`, on the default store or the one named. */\nexport function registerCacheCommands(kernel: ConsoleKernel, app: Application): void {\n kernel\n .command('cache:clear {store? : The name of the store you would like to clear}', async function (this: CommandContext) {\n let flushed: boolean\n try {\n flushed = await app.make(CacheManager).store(storeName(this)).flush()\n } catch (error) {\n this.error(error instanceof Error ? error.message : String(error))\n return 1\n }\n if (!flushed) {\n this.error('Failed to clear cache. Make sure you have the appropriate permissions.')\n return 1\n }\n this.info('Application cache cleared successfully.')\n return 0\n })\n .purpose('Flush the application cache')\n\n kernel\n .command(\n 'cache:forget {key : The key to remove} {store? : The store to remove the key from}',\n async function (this: CommandContext) {\n const key = String(this.argument('key'))\n try {\n await app.make(CacheManager).store(storeName(this)).forget(key)\n } catch (error) {\n this.error(error instanceof Error ? error.message : String(error))\n return 1\n }\n this.info(`The [${key}] key has been removed from the cache.`)\n return 0\n },\n )\n .purpose('Remove an item from the cache')\n}\n"],"mappings":";AAEO,IAAM,mBAAN,cAA+B,MAA4B;AAAA,EAIhE,YAAqB,UAAkB;AACrC,UAAM,2BAA2B,QAAQ,IAAI;AAD1B;AAAA,EAErB;AAAA,EAFqB;AAAA,EAHZ,OAAO;AAAA,EACP,SAAS;AAAA,EACA,OAAO;AAI3B;AAEO,IAAM,wBAAN,cAAoC,MAA4B;AAAA,EAC5D,OAAO;AAAA,EACP,SAAS;AAAA,EACA,OAAO;AAAA,EACzB,YAAY,OAAe;AACzB,UAAM,QAAQ,KAAK,iEAAiE;AAAA,EACtF;AACF;AAEO,IAAM,yBAAN,cAAqC,MAA4B;AAAA,EAC7D,OAAO;AAAA,EACP,SAAS;AAAA,EACA,OAAO;AAAA,EACzB,YAAY,MAAc;AACxB,UAAM,gBAAgB,IAAI,wDAAwD;AAAA,EACpF;AACF;AAEO,IAAM,0BAAN,cAAsC,MAA4B;AAAA,EAC9D,OAAO;AAAA,EACP,SAAS;AAAA,EACA,OAAO;AAAA,EACzB,YAAY,QAAgB;AAC1B,UAAM,iBAAiB,MAAM,mEAAmE;AAAA,EAClG;AACF;AAEO,IAAM,0BAAN,cAAsC,MAA4B;AAAA,EAC9D,OAAO;AAAA,EACP,SAAS;AAAA,EACA,OAAO;AAC3B;;;ACjCO,SAAS,UAAU,OAAwB;AAChD,SAAO,KAAK,UAAU,KAAK,KAAK;AAClC;AAEO,SAAS,YAAY,KAAsB;AAChD,SAAO,KAAK,MAAM,GAAG;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A,IACF;AACA,SAAK,IAAI,UAAUC,oBAAmB,CAAC,cAAc,IAAI,aAAa,SAAS,CAAC;AAEhF,SAAK,IAAI,WAAW,YAAY;AAC9B,UAAI,CAAC,KAAK,IAAI,SAASA,kBAAiB,EAAG;AAC3C,YAAO,KAAK,IAAI,KAAKA,kBAAiB,EAA0C,gBAAgB;AAAA,IAClG,CAAC;AAED,SAAK,IAAI,UAAUC,cAAa,CAAC,cAAc;AAC7C,aAAO,IAAI,iBAAiB,MAAM;AAChC,cAAM,OAAO,UAAU,KAAKC,iBAAgB,EAAE,IAAwB,iBAAiB,MAAS;AAChG,eAAO,UAAU,KAAKF,kBAAiB,EAAE,MAAM,SAAS,UAAa,SAAS,KAAK,SAAY,IAAI;AAAA,MACrG,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AAAA,EAES,OAAa;AACpB,QAAI,KAAK,IAAI,MAAM,aAAa,EAAG,uBAAsB,KAAK,IAAI,KAAK,aAAa,GAAG,KAAK,GAAG;AAAA,EACjG;AACF;","names":["now","now","sleep","Str","FOREVER_SECONDS","now","Str","sleep","createHash","createHash","sleep","Str","Str","sleep","storeName","now","cache","CacheManagerToken","CacheManagerToken","ConfigRepository","RateLimiter","CacheManager","CacheManagerToken","RateLimiter","ConfigRepository"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orieljs/cache",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
4
|
-
"description": "The Oriel
|
|
3
|
+
"version": "0.1.0-alpha.16",
|
|
4
|
+
"description": "The Oriel cache, as Laravel's: array, memory, file, database and Redis stores behind one API, with locks and limits.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"homepage": "https://orieljs.vercel.app",
|
|
@@ -31,10 +31,20 @@
|
|
|
31
31
|
"TRADEMARKS.md"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"
|
|
35
|
-
"@orieljs/support": "0.1.0-alpha.
|
|
36
|
-
"@orieljs/
|
|
37
|
-
|
|
34
|
+
"@orieljs/container": "0.1.0-alpha.16",
|
|
35
|
+
"@orieljs/support": "0.1.0-alpha.16",
|
|
36
|
+
"@orieljs/contracts": "0.1.0-alpha.16"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"ioredis": "6.0.0"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"ioredis": "^6.0.0"
|
|
43
|
+
},
|
|
44
|
+
"peerDependenciesMeta": {
|
|
45
|
+
"ioredis": {
|
|
46
|
+
"optional": true
|
|
47
|
+
}
|
|
38
48
|
},
|
|
39
49
|
"scripts": {
|
|
40
50
|
"build": "tsup && node ../../../scripts/copy-license.mjs"
|