@lakutata/cache 3.0.0-beta.0

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.
Files changed (116) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +175 -0
  3. package/dist/cjs/cache/Cacher.d.ts +446 -0
  4. package/dist/cjs/cache/Cacher.js +523 -0
  5. package/dist/cjs/cache/exceptions/CacheDriverNotFoundException.d.ts +10 -0
  6. package/dist/cjs/cache/exceptions/CacheDriverNotFoundException.js +17 -0
  7. package/dist/cjs/cache/interfaces/CacherOptions.d.ts +42 -0
  8. package/dist/cjs/cache/interfaces/CacherOptions.js +2 -0
  9. package/dist/cjs/cache/lib/LikePrefix.d.ts +5 -0
  10. package/dist/cjs/cache/lib/LikePrefix.js +10 -0
  11. package/dist/cjs/cache/lib/LoadDriver.d.ts +6 -0
  12. package/dist/cjs/cache/lib/LoadDriver.js +66 -0
  13. package/dist/cjs/cache/lib/Serializer.d.ts +18 -0
  14. package/dist/cjs/cache/lib/Serializer.js +46 -0
  15. package/dist/cjs/cache/lib/WithTimeout.d.ts +7 -0
  16. package/dist/cjs/cache/lib/WithTimeout.js +23 -0
  17. package/dist/cjs/cache/options/FileCacheOptions.d.ts +54 -0
  18. package/dist/cjs/cache/options/FileCacheOptions.js +62 -0
  19. package/dist/cjs/cache/options/MemcacheCacheOptions.d.ts +57 -0
  20. package/dist/cjs/cache/options/MemcacheCacheOptions.js +66 -0
  21. package/dist/cjs/cache/options/MemoryCacheOptions.d.ts +39 -0
  22. package/dist/cjs/cache/options/MemoryCacheOptions.js +52 -0
  23. package/dist/cjs/cache/options/MongoCacheOptions.d.ts +72 -0
  24. package/dist/cjs/cache/options/MongoCacheOptions.js +81 -0
  25. package/dist/cjs/cache/options/MysqlCacheOptions.d.ts +73 -0
  26. package/dist/cjs/cache/options/MysqlCacheOptions.js +82 -0
  27. package/dist/cjs/cache/options/PostgresCacheOptions.d.ts +87 -0
  28. package/dist/cjs/cache/options/PostgresCacheOptions.js +92 -0
  29. package/dist/cjs/cache/options/RedisCacheOptions.d.ts +120 -0
  30. package/dist/cjs/cache/options/RedisCacheOptions.js +113 -0
  31. package/dist/cjs/cache/options/SqliteCacheOptions.d.ts +53 -0
  32. package/dist/cjs/cache/options/SqliteCacheOptions.js +61 -0
  33. package/dist/cjs/cache/stores/CacheStore.d.ts +44 -0
  34. package/dist/cjs/cache/stores/CacheStore.js +42 -0
  35. package/dist/cjs/cache/stores/CreateCacheStore.d.ts +7 -0
  36. package/dist/cjs/cache/stores/CreateCacheStore.js +37 -0
  37. package/dist/cjs/cache/stores/FileStore.d.ts +51 -0
  38. package/dist/cjs/cache/stores/FileStore.js +143 -0
  39. package/dist/cjs/cache/stores/MemcacheStore.d.ts +42 -0
  40. package/dist/cjs/cache/stores/MemcacheStore.js +69 -0
  41. package/dist/cjs/cache/stores/MemoryStore.d.ts +34 -0
  42. package/dist/cjs/cache/stores/MemoryStore.js +75 -0
  43. package/dist/cjs/cache/stores/MongoStore.d.ts +55 -0
  44. package/dist/cjs/cache/stores/MongoStore.js +72 -0
  45. package/dist/cjs/cache/stores/MysqlStore.d.ts +27 -0
  46. package/dist/cjs/cache/stores/MysqlStore.js +71 -0
  47. package/dist/cjs/cache/stores/PostgresStore.d.ts +30 -0
  48. package/dist/cjs/cache/stores/PostgresStore.js +85 -0
  49. package/dist/cjs/cache/stores/RedisStore.d.ts +58 -0
  50. package/dist/cjs/cache/stores/RedisStore.js +131 -0
  51. package/dist/cjs/cache/stores/SerializedCacheStore.d.ts +48 -0
  52. package/dist/cjs/cache/stores/SerializedCacheStore.js +80 -0
  53. package/dist/cjs/cache/stores/SqliteStore.d.ts +44 -0
  54. package/dist/cjs/cache/stores/SqliteStore.js +91 -0
  55. package/dist/cjs/cache/types/CacheStoreOptions.d.ts +15 -0
  56. package/dist/cjs/cache/types/CacheStoreOptions.js +2 -0
  57. package/dist/cjs/exports/Cache.d.ts +12 -0
  58. package/dist/cjs/exports/Cache.js +31 -0
  59. package/dist/cjs/package.json +1 -0
  60. package/dist/esm/cache/Cacher.js +518 -0
  61. package/dist/esm/cache/exceptions/CacheDriverNotFoundException.js +13 -0
  62. package/dist/esm/cache/interfaces/CacherOptions.js +1 -0
  63. package/dist/esm/cache/lib/LikePrefix.js +7 -0
  64. package/dist/esm/cache/lib/LoadDriver.js +30 -0
  65. package/dist/esm/cache/lib/Serializer.js +42 -0
  66. package/dist/esm/cache/lib/WithTimeout.js +20 -0
  67. package/dist/esm/cache/options/FileCacheOptions.js +58 -0
  68. package/dist/esm/cache/options/MemcacheCacheOptions.js +62 -0
  69. package/dist/esm/cache/options/MemoryCacheOptions.js +48 -0
  70. package/dist/esm/cache/options/MongoCacheOptions.js +77 -0
  71. package/dist/esm/cache/options/MysqlCacheOptions.js +78 -0
  72. package/dist/esm/cache/options/PostgresCacheOptions.js +88 -0
  73. package/dist/esm/cache/options/RedisCacheOptions.js +109 -0
  74. package/dist/esm/cache/options/SqliteCacheOptions.js +57 -0
  75. package/dist/esm/cache/stores/CacheStore.js +36 -0
  76. package/dist/esm/cache/stores/CreateCacheStore.js +34 -0
  77. package/dist/esm/cache/stores/FileStore.js +136 -0
  78. package/dist/esm/cache/stores/MemcacheStore.js +65 -0
  79. package/dist/esm/cache/stores/MemoryStore.js +71 -0
  80. package/dist/esm/cache/stores/MongoStore.js +68 -0
  81. package/dist/esm/cache/stores/MysqlStore.js +67 -0
  82. package/dist/esm/cache/stores/PostgresStore.js +81 -0
  83. package/dist/esm/cache/stores/RedisStore.js +127 -0
  84. package/dist/esm/cache/stores/SerializedCacheStore.js +76 -0
  85. package/dist/esm/cache/stores/SqliteStore.js +87 -0
  86. package/dist/esm/cache/types/CacheStoreOptions.js +1 -0
  87. package/dist/esm/exports/Cache.js +12 -0
  88. package/dist/types/cache/Cacher.d.ts +446 -0
  89. package/dist/types/cache/exceptions/CacheDriverNotFoundException.d.ts +10 -0
  90. package/dist/types/cache/interfaces/CacherOptions.d.ts +42 -0
  91. package/dist/types/cache/lib/LikePrefix.d.ts +5 -0
  92. package/dist/types/cache/lib/LoadDriver.d.ts +6 -0
  93. package/dist/types/cache/lib/Serializer.d.ts +18 -0
  94. package/dist/types/cache/lib/WithTimeout.d.ts +7 -0
  95. package/dist/types/cache/options/FileCacheOptions.d.ts +54 -0
  96. package/dist/types/cache/options/MemcacheCacheOptions.d.ts +57 -0
  97. package/dist/types/cache/options/MemoryCacheOptions.d.ts +39 -0
  98. package/dist/types/cache/options/MongoCacheOptions.d.ts +72 -0
  99. package/dist/types/cache/options/MysqlCacheOptions.d.ts +73 -0
  100. package/dist/types/cache/options/PostgresCacheOptions.d.ts +87 -0
  101. package/dist/types/cache/options/RedisCacheOptions.d.ts +120 -0
  102. package/dist/types/cache/options/SqliteCacheOptions.d.ts +53 -0
  103. package/dist/types/cache/stores/CacheStore.d.ts +44 -0
  104. package/dist/types/cache/stores/CreateCacheStore.d.ts +7 -0
  105. package/dist/types/cache/stores/FileStore.d.ts +51 -0
  106. package/dist/types/cache/stores/MemcacheStore.d.ts +42 -0
  107. package/dist/types/cache/stores/MemoryStore.d.ts +34 -0
  108. package/dist/types/cache/stores/MongoStore.d.ts +55 -0
  109. package/dist/types/cache/stores/MysqlStore.d.ts +27 -0
  110. package/dist/types/cache/stores/PostgresStore.d.ts +30 -0
  111. package/dist/types/cache/stores/RedisStore.d.ts +58 -0
  112. package/dist/types/cache/stores/SerializedCacheStore.d.ts +48 -0
  113. package/dist/types/cache/stores/SqliteStore.d.ts +44 -0
  114. package/dist/types/cache/types/CacheStoreOptions.d.ts +15 -0
  115. package/dist/types/exports/Cache.d.ts +12 -0
  116. package/package.json +72 -0
@@ -0,0 +1,42 @@
1
+ import { SerializedCacheStore, SerializedEntry } from './SerializedCacheStore.js';
2
+ import { MemcacheCacheOptions } from '../options/MemcacheCacheOptions.js';
3
+ interface MemcacheClient {
4
+ get(key: string): Promise<{
5
+ value: Buffer | null;
6
+ }>;
7
+ set(key: string, value: string, options: {
8
+ expires?: number;
9
+ }): Promise<boolean>;
10
+ delete(key: string): Promise<boolean>;
11
+ flush(): Promise<unknown>;
12
+ close(): void;
13
+ }
14
+ /**
15
+ * The Memcache store
16
+ * Key format: "{namespace}:{namespace}:{key}", or "{key}" without namespace
17
+ */
18
+ export declare class MemcacheStore extends SerializedCacheStore {
19
+ protected readonly options: MemcacheCacheOptions;
20
+ protected client: MemcacheClient;
21
+ constructor(options: MemcacheCacheOptions);
22
+ protected storeKey(key: string): string;
23
+ /**
24
+ * The memcached expiration of an entry, the entries expire after their expiration time
25
+ * @param entry
26
+ * @protected
27
+ */
28
+ protected expiration(entry: SerializedEntry): number;
29
+ connect(): Promise<void>;
30
+ disconnect(): Promise<void>;
31
+ protected read(key: string): Promise<string | undefined>;
32
+ protected readMany(keys: string[]): Promise<(string | undefined)[]>;
33
+ protected write(entry: SerializedEntry): Promise<void>;
34
+ protected writeMany(entries: SerializedEntry[]): Promise<void>;
35
+ protected remove(key: string): Promise<boolean>;
36
+ protected removeMany(keys: string[]): Promise<boolean>;
37
+ /**
38
+ * Memcached cannot list the keys, all the entries are flushed
39
+ */
40
+ clear(): Promise<void>;
41
+ }
42
+ export {};
@@ -0,0 +1,34 @@
1
+ import { CacheStore, CacheStoreSetEntry } from './CacheStore.js';
2
+ import { CacheEntry } from '../lib/Serializer.js';
3
+ /**
4
+ * The in-memory store, the values are kept by reference
5
+ */
6
+ export declare class MemoryStore extends CacheStore {
7
+ protected readonly sweepInterval: number;
8
+ protected readonly entries: Map<string, CacheEntry>;
9
+ protected sweeper?: NodeJS.Timeout;
10
+ /**
11
+ * @param sweepInterval ms, remove the expired entries in each interval
12
+ */
13
+ constructor(sweepInterval?: number);
14
+ /**
15
+ * Remove the expired entries
16
+ * @protected
17
+ */
18
+ protected sweep(): void;
19
+ connect(): Promise<void>;
20
+ disconnect(): Promise<void>;
21
+ /**
22
+ * Read an entry, the expired entries are removed
23
+ * @param key
24
+ * @protected
25
+ */
26
+ protected read(key: string): CacheEntry | undefined;
27
+ get(key: string): Promise<CacheEntry | undefined>;
28
+ getMany(keys: string[]): Promise<(CacheEntry | undefined)[]>;
29
+ set(key: string, value: unknown, ttl?: number): Promise<void>;
30
+ setMany(entries: CacheStoreSetEntry[]): Promise<void>;
31
+ delete(key: string): Promise<boolean>;
32
+ deleteMany(keys: string[]): Promise<boolean>;
33
+ clear(): Promise<void>;
34
+ }
@@ -0,0 +1,55 @@
1
+ import { SerializedCacheStore, SerializedEntry } from './SerializedCacheStore.js';
2
+ import { MongoCacheOptions } from '../options/MongoCacheOptions.js';
3
+ type MongoDocument = {
4
+ key: string;
5
+ value: string;
6
+ expiresAt?: Date | null;
7
+ };
8
+ interface MongoCollection {
9
+ createIndex(keys: Record<string, number>, options: Record<string, unknown>): Promise<unknown>;
10
+ findOne(filter: Record<string, unknown>, options?: Record<string, unknown>): Promise<MongoDocument | null>;
11
+ find(filter: Record<string, unknown>, options?: Record<string, unknown>): {
12
+ toArray(): Promise<MongoDocument[]>;
13
+ };
14
+ updateOne(filter: Record<string, unknown>, update: Record<string, unknown>, options: Record<string, unknown>): Promise<unknown>;
15
+ bulkWrite(operations: Record<string, unknown>[], options: Record<string, unknown>): Promise<unknown>;
16
+ deleteOne(filter: Record<string, unknown>): Promise<{
17
+ deletedCount: number;
18
+ }>;
19
+ deleteMany(filter: Record<string, unknown>): Promise<{
20
+ deletedCount: number;
21
+ }>;
22
+ }
23
+ interface MongoClient {
24
+ connect(): Promise<unknown>;
25
+ close(): Promise<void>;
26
+ db(name: string): {
27
+ collection(name: string): MongoCollection;
28
+ };
29
+ }
30
+ /**
31
+ * The MongoDB store
32
+ * Document format: {key: "{namespace}:{key}", value: serialized entry, expiresAt: Date | null}, removed by a TTL index
33
+ */
34
+ export declare class MongoStore extends SerializedCacheStore {
35
+ protected readonly options: MongoCacheOptions;
36
+ protected client: MongoClient;
37
+ protected collection: MongoCollection;
38
+ constructor(options: MongoCacheOptions);
39
+ connect(): Promise<void>;
40
+ disconnect(): Promise<void>;
41
+ protected read(key: string): Promise<string | undefined>;
42
+ protected readMany(keys: string[]): Promise<(string | undefined)[]>;
43
+ /**
44
+ * The upsert of an entry
45
+ * @param entry
46
+ * @protected
47
+ */
48
+ protected update(entry: SerializedEntry): [Record<string, unknown>, Record<string, unknown>];
49
+ protected write(entry: SerializedEntry): Promise<void>;
50
+ protected writeMany(entries: SerializedEntry[]): Promise<void>;
51
+ protected remove(key: string): Promise<boolean>;
52
+ protected removeMany(keys: string[]): Promise<boolean>;
53
+ clear(): Promise<void>;
54
+ }
55
+ export {};
@@ -0,0 +1,27 @@
1
+ import { SerializedCacheStore, SerializedEntry } from './SerializedCacheStore.js';
2
+ import { MysqlCacheOptions } from '../options/MysqlCacheOptions.js';
3
+ interface MysqlPool {
4
+ query(sql: string, values?: unknown[]): Promise<[any, unknown]>;
5
+ escapeId(identifier: string): string;
6
+ end(): Promise<void>;
7
+ }
8
+ /**
9
+ * The MySQL store
10
+ * Table format: (id VARCHAR(255) PRIMARY KEY, value TEXT), with "{namespace}:{key}" ids
11
+ */
12
+ export declare class MysqlStore extends SerializedCacheStore {
13
+ protected readonly options: MysqlCacheOptions;
14
+ protected pool: MysqlPool;
15
+ protected table: string;
16
+ constructor(options: MysqlCacheOptions);
17
+ connect(): Promise<void>;
18
+ disconnect(): Promise<void>;
19
+ protected read(key: string): Promise<string | undefined>;
20
+ protected readMany(keys: string[]): Promise<(string | undefined)[]>;
21
+ protected write(entry: SerializedEntry): Promise<void>;
22
+ protected writeMany(entries: SerializedEntry[]): Promise<void>;
23
+ protected remove(key: string): Promise<boolean>;
24
+ protected removeMany(keys: string[]): Promise<boolean>;
25
+ clear(): Promise<void>;
26
+ }
27
+ export {};
@@ -0,0 +1,30 @@
1
+ import { SerializedCacheStore, SerializedEntry } from './SerializedCacheStore.js';
2
+ import { PostgresCacheOptions } from '../options/PostgresCacheOptions.js';
3
+ interface PostgresPool {
4
+ query(sql: string, values?: unknown[]): Promise<{
5
+ rows: any[];
6
+ rowCount: number | null;
7
+ }>;
8
+ on(event: string, listener: (...args: any[]) => void): unknown;
9
+ end(): Promise<void>;
10
+ }
11
+ /**
12
+ * The PostgreSQL store
13
+ * Table format: (key VARCHAR(255) PRIMARY KEY, value TEXT), with "{namespace}:{key}" keys
14
+ */
15
+ export declare class PostgresStore extends SerializedCacheStore {
16
+ protected readonly options: PostgresCacheOptions;
17
+ protected pool: PostgresPool;
18
+ protected table: string;
19
+ constructor(options: PostgresCacheOptions);
20
+ connect(): Promise<void>;
21
+ disconnect(): Promise<void>;
22
+ protected read(key: string): Promise<string | undefined>;
23
+ protected readMany(keys: string[]): Promise<(string | undefined)[]>;
24
+ protected write(entry: SerializedEntry): Promise<void>;
25
+ protected writeMany(entries: SerializedEntry[]): Promise<void>;
26
+ protected remove(key: string): Promise<boolean>;
27
+ protected removeMany(keys: string[]): Promise<boolean>;
28
+ clear(): Promise<void>;
29
+ }
30
+ export {};
@@ -0,0 +1,58 @@
1
+ import { SerializedCacheStore, SerializedEntry } from './SerializedCacheStore.js';
2
+ import { RedisCacheOptions } from '../options/RedisCacheOptions.js';
3
+ interface RedisCommands<R> {
4
+ set(key: string, value: string): R;
5
+ pSetEx(key: string, milliseconds: number, value: string): R;
6
+ }
7
+ interface RedisMulti extends RedisCommands<RedisMulti> {
8
+ exec(): Promise<unknown[]>;
9
+ }
10
+ interface RedisClient extends RedisCommands<Promise<unknown>> {
11
+ isOpen: boolean;
12
+ isReady: boolean;
13
+ on(event: string, listener: (...args: any[]) => void): unknown;
14
+ connect(): Promise<unknown>;
15
+ disconnect(): Promise<unknown>;
16
+ quit?(): Promise<unknown>;
17
+ close?(): Promise<unknown>;
18
+ destroy?(): void;
19
+ get(key: string): Promise<string | null>;
20
+ mGet(keys: string[]): Promise<(string | null)[]>;
21
+ del(keys: string | string[]): Promise<number>;
22
+ unlink(keys: string | string[]): Promise<number>;
23
+ flushDb(): Promise<unknown>;
24
+ multi(): RedisMulti;
25
+ scanIterator(options: {
26
+ MATCH?: string;
27
+ COUNT?: number;
28
+ TYPE?: string;
29
+ }): AsyncIterable<string | string[]>;
30
+ }
31
+ /**
32
+ * The Redis store
33
+ * Key format: "{namespace}{keyPrefixSeparator}{namespace}:{key}", or "{key}" without namespace
34
+ */
35
+ export declare class RedisStore extends SerializedCacheStore {
36
+ protected readonly options: RedisCacheOptions;
37
+ protected readonly separator: string;
38
+ protected readonly clearBatchSize: number;
39
+ protected client: RedisClient;
40
+ constructor(options: RedisCacheOptions);
41
+ protected storeKey(key: string): string;
42
+ connect(): Promise<void>;
43
+ disconnect(): Promise<void>;
44
+ protected read(key: string): Promise<string | undefined>;
45
+ protected readMany(keys: string[]): Promise<(string | undefined)[]>;
46
+ protected write(entry: SerializedEntry): Promise<void>;
47
+ protected writeMany(entries: SerializedEntry[]): Promise<void>;
48
+ /**
49
+ * Delete keys
50
+ * @param keys
51
+ * @protected
52
+ */
53
+ protected unlink(keys: string | string[]): Promise<number>;
54
+ protected remove(key: string): Promise<boolean>;
55
+ protected removeMany(keys: string[]): Promise<boolean>;
56
+ clear(): Promise<void>;
57
+ }
58
+ export {};
@@ -0,0 +1,48 @@
1
+ import { CacheStore, CacheStoreSetEntry } from './CacheStore.js';
2
+ import { CacheEntry } from '../lib/Serializer.js';
3
+ export type SerializedEntry = {
4
+ key: string;
5
+ data: string;
6
+ ttl?: number;
7
+ expires?: number;
8
+ };
9
+ /**
10
+ * A store keeping the entries serialized, under namespaced keys
11
+ */
12
+ export declare abstract class SerializedCacheStore extends CacheStore {
13
+ protected readonly namespace?: string;
14
+ protected constructor(namespace?: string);
15
+ /**
16
+ * The key of an entry in the backend
17
+ * @param key
18
+ * @protected
19
+ */
20
+ protected storeKey(key: string): string;
21
+ protected abstract read(key: string): Promise<string | undefined>;
22
+ protected abstract readMany(keys: string[]): Promise<(string | undefined)[]>;
23
+ protected abstract write(entry: SerializedEntry): Promise<void>;
24
+ protected abstract writeMany(entries: SerializedEntry[]): Promise<void>;
25
+ protected abstract remove(key: string): Promise<boolean>;
26
+ protected abstract removeMany(keys: string[]): Promise<boolean>;
27
+ /**
28
+ * Parse an entry read from the backend, the expired entries are removed
29
+ * @param storeKey
30
+ * @param data
31
+ * @protected
32
+ */
33
+ protected parse(storeKey: string, data: string | undefined): CacheEntry | undefined;
34
+ /**
35
+ * Serialize an entry
36
+ * @param key
37
+ * @param value
38
+ * @param ttl
39
+ * @protected
40
+ */
41
+ protected serialize(key: string, value: unknown, ttl?: number): SerializedEntry;
42
+ get(key: string): Promise<CacheEntry | undefined>;
43
+ getMany(keys: string[]): Promise<(CacheEntry | undefined)[]>;
44
+ set(key: string, value: unknown, ttl?: number): Promise<void>;
45
+ setMany(entries: CacheStoreSetEntry[]): Promise<void>;
46
+ delete(key: string): Promise<boolean>;
47
+ deleteMany(keys: string[]): Promise<boolean>;
48
+ }
@@ -0,0 +1,44 @@
1
+ import { SerializedCacheStore, SerializedEntry } from './SerializedCacheStore.js';
2
+ import { SqliteCacheOptions } from '../options/SqliteCacheOptions.js';
3
+ interface SqliteDatabase {
4
+ configure(option: 'busyTimeout', value: number): void;
5
+ all(sql: string, params: unknown[], callback: (error: Error | null, rows: any[]) => void): void;
6
+ run(sql: string, params: unknown[], callback: (this: {
7
+ changes: number;
8
+ }, error: Error | null) => void): void;
9
+ close(callback: (error: Error | null) => void): void;
10
+ }
11
+ /**
12
+ * The SQLite store
13
+ * Table format: (key VARCHAR(255) PRIMARY KEY, value TEXT), with "{namespace}:{key}" keys
14
+ */
15
+ export declare class SqliteStore extends SerializedCacheStore {
16
+ protected readonly options: SqliteCacheOptions;
17
+ protected database: SqliteDatabase;
18
+ protected readonly table: string;
19
+ constructor(options: SqliteCacheOptions);
20
+ /**
21
+ * Query the rows
22
+ * @param sql
23
+ * @param params
24
+ * @protected
25
+ */
26
+ protected all(sql: string, params: unknown[]): Promise<any[]>;
27
+ /**
28
+ * Run a statement, resolve the number of changed rows
29
+ * @param sql
30
+ * @param params
31
+ * @protected
32
+ */
33
+ protected run(sql: string, params?: unknown[]): Promise<number>;
34
+ connect(): Promise<void>;
35
+ disconnect(): Promise<void>;
36
+ protected read(key: string): Promise<string | undefined>;
37
+ protected readMany(keys: string[]): Promise<(string | undefined)[]>;
38
+ protected write(entry: SerializedEntry): Promise<void>;
39
+ protected writeMany(entries: SerializedEntry[]): Promise<void>;
40
+ protected remove(key: string): Promise<boolean>;
41
+ protected removeMany(keys: string[]): Promise<boolean>;
42
+ clear(): Promise<void>;
43
+ }
44
+ export {};
@@ -0,0 +1,15 @@
1
+ import { FileCacheOptions } from '../options/FileCacheOptions.js';
2
+ import { MemoryCacheOptions } from '../options/MemoryCacheOptions.js';
3
+ import { RedisCacheOptions } from '../options/RedisCacheOptions.js';
4
+ import { SqliteCacheOptions } from '../options/SqliteCacheOptions.js';
5
+ import { PostgresCacheOptions } from '../options/PostgresCacheOptions.js';
6
+ import { MysqlCacheOptions } from '../options/MysqlCacheOptions.js';
7
+ import { MongoCacheOptions } from '../options/MongoCacheOptions.js';
8
+ import { MemcacheCacheOptions } from '../options/MemcacheCacheOptions.js';
9
+ /**
10
+ * The options of one store of a `Cacher`, told apart by their `type`: `'memory'` ({@link MemoryCacheOptions}, the
11
+ * store of a cache without stores), `'file'` ({@link FileCacheOptions}), `'redis'` ({@link RedisCacheOptions}),
12
+ * `'memcache'` ({@link MemcacheCacheOptions}), `'mongo'` ({@link MongoCacheOptions}), `'sqlite'`
13
+ * ({@link SqliteCacheOptions}), `'postgres'` ({@link PostgresCacheOptions}) or `'mysql'` ({@link MysqlCacheOptions}).
14
+ */
15
+ export type CacheStoreOptions = MemoryCacheOptions | FileCacheOptions | RedisCacheOptions | MemcacheCacheOptions | MongoCacheOptions | SqliteCacheOptions | PostgresCacheOptions | MysqlCacheOptions;
@@ -0,0 +1,12 @@
1
+ export * from '../cache/Cacher.js';
2
+ export * from '../cache/interfaces/CacherOptions.js';
3
+ export * from '../cache/options/FileCacheOptions.js';
4
+ export * from '../cache/options/MemoryCacheOptions.js';
5
+ export * from '../cache/options/MemcacheCacheOptions.js';
6
+ export * from '../cache/options/MongoCacheOptions.js';
7
+ export * from '../cache/options/MysqlCacheOptions.js';
8
+ export * from '../cache/options/PostgresCacheOptions.js';
9
+ export * from '../cache/options/RedisCacheOptions.js';
10
+ export * from '../cache/options/SqliteCacheOptions.js';
11
+ export * from '../cache/types/CacheStoreOptions.js';
12
+ export * from '../cache/exceptions/CacheDriverNotFoundException.js';
package/package.json ADDED
@@ -0,0 +1,72 @@
1
+ {
2
+ "name": "@lakutata/cache",
3
+ "version": "3.0.0-beta.0",
4
+ "description": "The cache component of the lakutata framework (memory, file, Redis, Memcache, MongoDB, SQLite, PostgreSQL, MySQL stores).",
5
+ "type": "module",
6
+ "main": "./dist/cjs/exports/Cache.js",
7
+ "types": "./dist/cjs/exports/Cache.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": {
11
+ "types": "./dist/types/exports/Cache.d.ts",
12
+ "default": "./dist/esm/exports/Cache.js"
13
+ },
14
+ "require": {
15
+ "types": "./dist/cjs/exports/Cache.d.ts",
16
+ "default": "./dist/cjs/exports/Cache.js"
17
+ }
18
+ },
19
+ "./package.json": "./package.json"
20
+ },
21
+ "scripts": {
22
+ "clean": "node -e \"require('node:fs').rmSync('dist', {recursive: true, force: true})\"",
23
+ "build:cjs": "tsc -p tsconfig.cjs.json",
24
+ "build:esm": "tsc -p tsconfig.esm.json",
25
+ "build:cjs-pkg": "node ../../scripts/package-build/cjs-package.mjs",
26
+ "build:js": "npm run build:cjs && npm run build:esm && npm run build:cjs-pkg",
27
+ "rebuild": "npm run clean && npm run build:js",
28
+ "compile": "npm run rebuild",
29
+ "test:unit": "npm run compile && node --test \"dist/esm/tests/*.spec.js\"",
30
+ "test:stores": "npm run compile && CACHE_TEST_STORES=1 node --test --test-concurrency=1 \"dist/esm/tests/stores/*.spec.js\""
31
+ },
32
+ "peerDependencies": {
33
+ "@lakutata/core": "3.0.0-beta.0",
34
+ "@lakutata/utils": "3.0.0-beta.0",
35
+ "memjs": "^1.3.2",
36
+ "mongodb": ">=6.0.0",
37
+ "mysql2": "^3.0.0",
38
+ "pg": "^8.0.0",
39
+ "redis": "^4.6.0 || ^5.0.0",
40
+ "sqlite3": "^5.0.0"
41
+ },
42
+ "peerDependenciesMeta": {
43
+ "memjs": {
44
+ "optional": true
45
+ },
46
+ "mongodb": {
47
+ "optional": true
48
+ },
49
+ "mysql2": {
50
+ "optional": true
51
+ },
52
+ "pg": {
53
+ "optional": true
54
+ },
55
+ "redis": {
56
+ "optional": true
57
+ },
58
+ "sqlite3": {
59
+ "optional": true
60
+ }
61
+ },
62
+ "engines": {
63
+ "node": ">=22"
64
+ },
65
+ "files": [
66
+ "dist",
67
+ "!dist/*/tests",
68
+ "*.md",
69
+ "LICENSE",
70
+ "package.json"
71
+ ]
72
+ }