@adonisjs/cache 1.2.0 → 2.0.1-next.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.
@@ -12,4 +12,3 @@ var __decorateClass = (decorators, target, key, kind) => {
12
12
  export {
13
13
  __decorateClass
14
14
  };
15
- //# sourceMappingURL=chunk-EUXUH3YW.js.map
@@ -1,5 +1,5 @@
1
1
  import { BaseCommand } from '@adonisjs/core/ace';
2
- import { CommandOptions } from '@adonisjs/core/types/ace';
2
+ import { type CommandOptions } from '@adonisjs/core/types/ace';
3
3
  export default class CacheClear extends BaseCommand {
4
4
  #private;
5
5
  static commandName: string;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __decorateClass
3
- } from "../chunk-EUXUH3YW.js";
3
+ } from "../chunk-ADS4GRIL.js";
4
4
 
5
5
  // commands/cache_clear.ts
6
6
  import { args, BaseCommand, flags } from "@adonisjs/core/ace";
@@ -85,4 +85,3 @@ __decorateClass([
85
85
  export {
86
86
  CacheClear as default
87
87
  };
88
- //# sourceMappingURL=cache_clear.js.map
@@ -1,5 +1,5 @@
1
1
  import { BaseCommand } from '@adonisjs/core/ace';
2
- import { CommandOptions } from '@adonisjs/core/types/ace';
2
+ import { type CommandOptions } from '@adonisjs/core/types/ace';
3
3
  export default class CacheDelete extends BaseCommand {
4
4
  #private;
5
5
  static commandName: string;
@@ -0,0 +1,69 @@
1
+ import {
2
+ __decorateClass
3
+ } from "../chunk-ADS4GRIL.js";
4
+
5
+ // commands/cache_delete.ts
6
+ import { args, BaseCommand } from "@adonisjs/core/ace";
7
+ var CacheDelete = class extends BaseCommand {
8
+ static commandName = "cache:delete";
9
+ static description = "Delete a specific cache entry by key";
10
+ static options = {
11
+ startApp: true
12
+ };
13
+ /**
14
+ * Prompts to take consent when deleting cache entry in production
15
+ */
16
+ async #takeProductionConsent() {
17
+ const question = `You are in production environment. Want to continue deleting cache key "${this.key}"?`;
18
+ try {
19
+ return await this.prompt.confirm(question);
20
+ } catch (error) {
21
+ return false;
22
+ }
23
+ }
24
+ /**
25
+ * Check if the given cache exist
26
+ */
27
+ #cacheExists(cache, cacheName) {
28
+ try {
29
+ cache.use(cacheName);
30
+ return true;
31
+ } catch (error) {
32
+ return false;
33
+ }
34
+ }
35
+ /**
36
+ * Handle command
37
+ */
38
+ async run() {
39
+ const cache = await this.app.container.make("cache.manager");
40
+ this.store = this.store || cache.defaultStoreName;
41
+ if (!this.#cacheExists(cache, this.store)) {
42
+ this.logger.error(
43
+ `"${this.store}" is not a valid cache store. Double check config/cache.ts file`
44
+ );
45
+ this.exitCode = 1;
46
+ return;
47
+ }
48
+ if (this.app.inProduction) {
49
+ const shouldDelete = await this.#takeProductionConsent();
50
+ if (!shouldDelete) return;
51
+ }
52
+ const cacheHandler = cache.use(this.store);
53
+ const deleted = await cacheHandler.delete({ key: this.key });
54
+ if (deleted) {
55
+ this.logger.success(`Deleted cache key "${this.key}" from "${this.store}" cache successfully`);
56
+ } else {
57
+ this.logger.warning(`Cache key "${this.key}" not found in "${this.store}" cache`);
58
+ }
59
+ }
60
+ };
61
+ __decorateClass([
62
+ args.string({ description: "The cache key to delete" })
63
+ ], CacheDelete.prototype, "key", 2);
64
+ __decorateClass([
65
+ args.string({ description: "Define a custom cache store to delete from", required: false })
66
+ ], CacheDelete.prototype, "store", 2);
67
+ export {
68
+ CacheDelete as default
69
+ };
@@ -0,0 +1,17 @@
1
+ import { BaseCommand } from '@adonisjs/core/ace';
2
+ import { type CommandOptions } from '@adonisjs/core/types/ace';
3
+ export default class CachePrune extends BaseCommand {
4
+ #private;
5
+ static commandName: string;
6
+ static description: string;
7
+ static options: CommandOptions;
8
+ /**
9
+ * Choose a custom cache store to prune. Otherwise, we use the
10
+ * default one
11
+ */
12
+ store: string;
13
+ /**
14
+ * Handle command
15
+ */
16
+ run(): Promise<void>;
17
+ }
@@ -0,0 +1,62 @@
1
+ import {
2
+ __decorateClass
3
+ } from "../chunk-ADS4GRIL.js";
4
+
5
+ // commands/cache_prune.ts
6
+ import { args, BaseCommand } from "@adonisjs/core/ace";
7
+ var CachePrune = class extends BaseCommand {
8
+ static commandName = "cache:prune";
9
+ static description = "Remove expired cache entries from the selected store. This command is only useful for stores without native TTL support, like Database or File drivers.";
10
+ static options = {
11
+ startApp: true
12
+ };
13
+ /**
14
+ * Prompts to take consent when pruning the cache in production
15
+ */
16
+ async #takeProductionConsent() {
17
+ const question = "You are in production environment. Want to continue pruning expired cache entries?";
18
+ try {
19
+ return await this.prompt.confirm(question);
20
+ } catch (error) {
21
+ return false;
22
+ }
23
+ }
24
+ /**
25
+ * Check if the given cache exist
26
+ */
27
+ #cacheExists(cache, cacheName) {
28
+ try {
29
+ cache.use(cacheName);
30
+ return true;
31
+ } catch (error) {
32
+ return false;
33
+ }
34
+ }
35
+ /**
36
+ * Handle command
37
+ */
38
+ async run() {
39
+ const cache = await this.app.container.make("cache.manager");
40
+ this.store = this.store || cache.defaultStoreName;
41
+ if (!this.#cacheExists(cache, this.store)) {
42
+ this.logger.error(
43
+ `"${this.store}" is not a valid cache store. Double check config/cache.ts file`
44
+ );
45
+ this.exitCode = 1;
46
+ return;
47
+ }
48
+ if (this.app.inProduction) {
49
+ const shouldPrune = await this.#takeProductionConsent();
50
+ if (!shouldPrune) return;
51
+ }
52
+ const cacheHandler = cache.use(this.store);
53
+ await cacheHandler.prune();
54
+ this.logger.success(`Pruned expired entries from "${this.store}" cache successfully`);
55
+ }
56
+ };
57
+ __decorateClass([
58
+ args.string({ description: "Define a custom cache store to prune", required: false })
59
+ ], CachePrune.prototype, "store", 2);
60
+ export {
61
+ CachePrune as default
62
+ };
@@ -1 +1 @@
1
- {"commands":[{"commandName":"cache:clear","description":"Clear the application cache","help":"","namespace":"cache","aliases":[],"flags":[{"name":"namespace","flagName":"namespace","required":false,"type":"string","description":"Select a cache namespace to clear","alias":"n"},{"name":"tags","flagName":"tags","required":false,"type":"array","description":"Specify tags to invalidate","alias":"t"}],"args":[{"name":"store","argumentName":"store","required":false,"description":"Define a custom cache store to clear","type":"string"}],"options":{"startApp":true},"filePath":"cache_clear.js"}],"version":1}
1
+ {"commands":[{"commandName":"cache:clear","description":"Clear the application cache","help":"","namespace":"cache","aliases":[],"flags":[{"name":"namespace","flagName":"namespace","required":false,"type":"string","description":"Select a cache namespace to clear","alias":"n"},{"name":"tags","flagName":"tags","required":false,"type":"array","description":"Specify tags to invalidate","alias":"t"}],"args":[{"name":"store","argumentName":"store","required":false,"description":"Define a custom cache store to clear","type":"string"}],"options":{"startApp":true},"filePath":"cache_clear.js"},{"commandName":"cache:delete","description":"Delete a specific cache entry by key","help":"","namespace":"cache","aliases":[],"flags":[],"args":[{"name":"key","argumentName":"key","required":true,"description":"The cache key to delete","type":"string"},{"name":"store","argumentName":"store","required":false,"description":"Define a custom cache store to delete from","type":"string"}],"options":{"startApp":true},"filePath":"cache_delete.js"},{"commandName":"cache:prune","description":"Remove expired cache entries from the selected store. This command is only useful for stores without native TTL support, like Database or File drivers.","help":"","namespace":"cache","aliases":[],"flags":[],"args":[{"name":"store","argumentName":"store","required":false,"description":"Define a custom cache store to prune","type":"string"}],"options":{"startApp":true},"filePath":"cache_prune.js"}],"version":1}
package/build/config.stub CHANGED
@@ -18,6 +18,8 @@ const cacheConfig = defineConfig({
18
18
  {{#if driver === 'database'}}
19
19
  .useL2Layer(drivers.database({
20
20
  connectionName: 'primary',
21
+ autoCreateTable: false,
22
+ tableName: 'cache',
21
23
  }))
22
24
  {{#elif driver === 'redis'}}
23
25
  .useL2Layer(drivers.redis({
package/build/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export * from 'bentocache';
2
- export { store } from './src/store.js';
3
- export { configure } from './configure.js';
4
- export { defineConfig } from './src/define_config.js';
5
- export { drivers } from './src/drivers.js';
2
+ export { store } from './src/store.ts';
3
+ export { configure } from './configure.ts';
4
+ export { defineConfig } from './src/define_config.ts';
5
+ export { drivers } from './src/drivers.ts';
package/build/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./chunk-EUXUH3YW.js";
1
+ import "./chunk-ADS4GRIL.js";
2
2
 
3
3
  // index.ts
4
4
  export * from "bentocache";
@@ -56,9 +56,7 @@ var Store = class {
56
56
  };
57
57
 
58
58
  // stubs/main.ts
59
- import { dirname } from "path";
60
- import { fileURLToPath } from "url";
61
- var stubsRoot = dirname(fileURLToPath(import.meta.url));
59
+ var stubsRoot = import.meta.dirname;
62
60
 
63
61
  // configure.ts
64
62
  var DRIVERS_INFO = {
@@ -100,6 +98,15 @@ async function configure(command) {
100
98
  await codemods.defineEnvValidations({ variables: envValidations });
101
99
  }
102
100
  await codemods.makeUsingStub(stubsRoot, "config.stub", { driver });
101
+ if (driver === "database") {
102
+ await codemods.makeUsingStub(stubsRoot, "migration.stub", {
103
+ entity: command.app.generators.createEntity("cache"),
104
+ migration: {
105
+ folder: "database/migrations",
106
+ fileName: `${(/* @__PURE__ */ new Date()).getTime()}_create_cache_table.ts`
107
+ }
108
+ });
109
+ }
103
110
  }
104
111
 
105
112
  // src/define_config.ts
@@ -120,7 +127,10 @@ var drivers = {
120
127
  const redis = await app.container.make("redis");
121
128
  const { redisDriver } = await import("bentocache/drivers/redis");
122
129
  const redisConnection = redis.connection(config.connectionName);
123
- return redisDriver({ connection: redisConnection.ioConnection });
130
+ return redisDriver({
131
+ connection: redisConnection.ioConnection,
132
+ prefix: config.prefix || "bentocache"
133
+ });
124
134
  });
125
135
  },
126
136
  /**
@@ -132,7 +142,10 @@ var drivers = {
132
142
  const redis = await app.container.make("redis");
133
143
  const { redisBusDriver } = await import("bentocache/drivers/redis");
134
144
  const redisConnection = redis.connection(config.connectionName);
135
- return redisBusDriver({ connection: redisConnection.ioConnection.options });
145
+ return redisBusDriver({
146
+ connection: redisConnection.ioConnection.options,
147
+ retryQueue: config.retryQueue
148
+ });
136
149
  });
137
150
  },
138
151
  /**
@@ -159,7 +172,13 @@ var drivers = {
159
172
  );
160
173
  }
161
174
  const { knexDriver } = await import("bentocache/drivers/knex");
162
- return knexDriver({ connection: db.connection(connectionName).getWriteClient() });
175
+ return knexDriver({
176
+ connection: db.connection(connectionName).getWriteClient(),
177
+ autoCreateTable: config?.autoCreateTable ?? true,
178
+ tableName: config?.tableName || "bentocache",
179
+ pruneInterval: config?.pruneInterval ?? false,
180
+ prefix: config?.prefix || "bentocache"
181
+ });
163
182
  });
164
183
  },
165
184
  /**
@@ -206,4 +225,3 @@ export {
206
225
  drivers,
207
226
  store
208
227
  };
209
- //# sourceMappingURL=index.js.map
@@ -0,0 +1,22 @@
1
+ {{{
2
+ exports({
3
+ to: app.makePath(migration.folder, entity.path, migration.fileName)
4
+ })
5
+ }}}
6
+ import { BaseSchema } from '@adonisjs/lucid/schema'
7
+
8
+ export default class extends BaseSchema {
9
+ protected tableName = 'cache'
10
+
11
+ async up() {
12
+ this.schema.createTable(this.tableName, (table) => {
13
+ table.string('key', 255).notNullable().primary()
14
+ table.text('value', 'longtext')
15
+ table.timestamp('expires_at').nullable()
16
+ })
17
+ }
18
+
19
+ async down() {
20
+ this.schema.dropTable(this.tableName)
21
+ }
22
+ }
@@ -1,6 +1,6 @@
1
1
  import type { ApplicationService } from '@adonisjs/core/types';
2
2
  import type { CacheEvents } from 'bentocache/types';
3
- import type { CacheService } from '../src/types.js';
3
+ import type { CacheService } from '../src/types.ts';
4
4
  /**
5
5
  * Extend Adonis.js types to include cache
6
6
  */
@@ -1,4 +1,4 @@
1
- import "../chunk-EUXUH3YW.js";
1
+ import "../chunk-ADS4GRIL.js";
2
2
 
3
3
  // src/bindings/repl.ts
4
4
  function setupReplState(repl, key, value) {
@@ -90,4 +90,3 @@ var CacheProvider = class {
90
90
  export {
91
91
  CacheProvider as default
92
92
  };
93
- //# sourceMappingURL=cache_provider.js.map
@@ -1,3 +1,3 @@
1
- import type { CacheService } from '../src/types.js';
1
+ import type { CacheService } from '../src/types.ts';
2
2
  declare let cache: CacheService;
3
3
  export { cache as default };
@@ -1,4 +1,4 @@
1
- import "../chunk-EUXUH3YW.js";
1
+ import "../chunk-ADS4GRIL.js";
2
2
 
3
3
  // services/main.ts
4
4
  import app from "@adonisjs/core/services/app";
@@ -9,4 +9,3 @@ await app.booted(async () => {
9
9
  export {
10
10
  cache as default
11
11
  };
12
- //# sourceMappingURL=main.js.map
@@ -1,2 +1,2 @@
1
- import { CacheService } from '../types.js';
1
+ import { type CacheService } from '../types.ts';
2
2
  export declare function registerViewBindings(manager: CacheService): Promise<void>;
@@ -1,5 +1,5 @@
1
- import { Store } from './store.js';
2
- import { CacheOptions } from './types.js';
1
+ import { type Store } from './store.ts';
2
+ import { type CacheOptions } from './types.ts';
3
3
  /**
4
4
  * Define cache configuration
5
5
  */
@@ -1,18 +1,18 @@
1
1
  import type { ConfigProvider } from '@adonisjs/core/types';
2
2
  import type { RedisConnections } from '@adonisjs/redis/types';
3
- import { MemoryConfig, CreateDriverResult, L1CacheDriver, L2CacheDriver, CreateBusDriverResult, DynamoDBConfig, FileConfig, KyselyConfig, OrchidConfig } from 'bentocache/types';
3
+ import { type MemoryConfig, type CreateDriverResult, type L1CacheDriver, type L2CacheDriver, type CreateBusDriverResult, type DynamoDBConfig, type FileConfig, type RedisConfig, type BusOptions, type KyselyConfig, type OrchidConfig, type DatabaseConfig } from 'bentocache/types';
4
4
  /**
5
5
  * Different drivers supported by the cache module
6
6
  */
7
7
  export declare const drivers: {
8
8
  memory: (config?: MemoryConfig) => ConfigProvider<CreateDriverResult<L1CacheDriver>>;
9
- redis: (config: {
9
+ redis: (config: Omit<RedisConfig, 'connection'> & {
10
10
  connectionName?: keyof RedisConnections;
11
11
  }) => ConfigProvider<CreateDriverResult<L2CacheDriver>>;
12
- redisBus: (config: {
12
+ redisBus: (config: BusOptions & {
13
13
  connectionName?: keyof RedisConnections;
14
14
  }) => ConfigProvider<CreateBusDriverResult>;
15
- database: (config?: {
15
+ database: (config?: DatabaseConfig & {
16
16
  connectionName?: string;
17
17
  }) => ConfigProvider<CreateDriverResult<L2CacheDriver>>;
18
18
  dynamodb: (config: DynamoDBConfig) => ConfigProvider<CreateDriverResult<L2CacheDriver>>;
@@ -1,5 +1,5 @@
1
1
  import type { ConfigProvider } from '@adonisjs/core/types';
2
- import { RawCommonOptions, CreateDriverResult, L1CacheDriver, CreateBusDriverResult, L2CacheDriver } from 'bentocache/types';
2
+ import { type RawCommonOptions, type CreateDriverResult, type L1CacheDriver, type CreateBusDriverResult, type L2CacheDriver } from 'bentocache/types';
3
3
  /**
4
4
  * Create a new store
5
5
  */
@@ -29,18 +29,5 @@ export declare class Store {
29
29
  /**
30
30
  * Create a config provider for the store
31
31
  */
32
- entry(): ConfigProvider<{
33
- "__#117@#private": any;
34
- useL1Layer(driver: CreateDriverResult<L1CacheDriver>): /*elided*/ any;
35
- useL2Layer(driver: CreateDriverResult<L2CacheDriver>): /*elided*/ any;
36
- useBus(bus: CreateBusDriverResult): /*elided*/ any;
37
- readonly entry: {
38
- options: RawCommonOptions & {
39
- prefix?: string;
40
- };
41
- l1: CreateDriverResult<L1CacheDriver> | undefined;
42
- l2: CreateDriverResult<L2CacheDriver> | undefined;
43
- bus: CreateBusDriverResult | undefined;
44
- };
45
- }>;
32
+ entry(): ConfigProvider<import("bentocache").BentoStore>;
46
33
  }
@@ -1,7 +1,7 @@
1
1
  export * from 'bentocache/types';
2
2
  import type { BentoCache, bentostore } from 'bentocache';
3
3
  import type { RawBentoCacheOptions } from 'bentocache/types';
4
- import type { store } from './store.js';
4
+ import type { store } from './store.ts';
5
5
  /**
6
6
  * The options accepted by the cache module
7
7
  */
@@ -1,3 +1,2 @@
1
1
  // src/types.ts
2
2
  export * from "bentocache/types";
3
- //# sourceMappingURL=types.js.map
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@adonisjs/cache",
3
3
  "description": "Official caching module for AdonisJS framework",
4
- "version": "1.2.0",
4
+ "version": "2.0.1-next.0",
5
5
  "engines": {
6
- "node": ">=20.6.0"
6
+ "node": ">=22.0.0"
7
7
  },
8
8
  "main": "build/index.js",
9
9
  "type": "module",
@@ -27,58 +27,57 @@
27
27
  "index:commands": "adonis-kit index build/commands",
28
28
  "lint": "eslint",
29
29
  "format": "prettier --write .",
30
- "quick:test": "node --enable-source-maps --import=ts-node-maintained/register/esm bin/test.ts",
30
+ "quick:test": "node --import=@poppinss/ts-exec --enable-source-maps bin/test.ts",
31
31
  "pretest": "npm run lint",
32
32
  "test": "c8 npm run quick:test",
33
33
  "prebuild": "npm run lint && npm run clean",
34
- "build": "tsup-node --metafile && tsc --emitDeclarationOnly --declaration",
34
+ "build": "tsup-node && tsc --emitDeclarationOnly --declaration",
35
35
  "postbuild": "npm run copy:templates && npm run index:commands",
36
36
  "release": "npx release-it",
37
37
  "version": "npm run build",
38
38
  "prepublishOnly": "npm run build"
39
39
  },
40
40
  "devDependencies": {
41
- "@adonisjs/assembler": "^7.8.2",
42
- "@adonisjs/core": "^6.18.0",
43
- "@adonisjs/eslint-config": "^2.1.0",
44
- "@adonisjs/lucid": "^21.6.1",
41
+ "@adonisjs/assembler": "^8.0.0-next.19",
42
+ "@adonisjs/core": "^7.0.0-next.13",
43
+ "@adonisjs/eslint-config": "^3.0.0-next.4",
44
+ "@adonisjs/lucid": "^22.0.0-next.1",
45
45
  "@adonisjs/prettier-config": "^1.4.5",
46
- "@adonisjs/redis": "^9.2.0",
47
- "@adonisjs/tsconfig": "^1.4.1",
48
- "@japa/assert": "^4.0.1",
46
+ "@adonisjs/redis": "^10.0.0-next.1",
47
+ "@adonisjs/tsconfig": "^2.0.0-next.3",
48
+ "@japa/assert": "^4.1.1",
49
49
  "@japa/expect-type": "^2.0.3",
50
50
  "@japa/file-system": "^2.3.2",
51
- "@japa/runner": "^4.2.0",
52
- "@japa/snapshot": "^2.0.8",
53
- "@release-it/conventional-changelog": "^10.0.1",
54
- "@swc/core": "^1.12.1",
55
- "@types/node": "~24.0.1",
56
- "better-sqlite3": "^11.10.0",
51
+ "@japa/runner": "^4.4.0",
52
+ "@japa/snapshot": "^2.0.9",
53
+ "@poppinss/ts-exec": "^1.4.1",
54
+ "@release-it/conventional-changelog": "^10.0.2",
55
+ "@types/node": "~24.10.1",
56
+ "better-sqlite3": "^12.5.0",
57
57
  "c8": "^10.1.3",
58
58
  "copyfiles": "^2.4.1",
59
- "del-cli": "^6.0.0",
60
- "edge.js": "^6.2.1",
61
- "eslint": "^9.29.0",
62
- "ioredis": "^5.6.1",
59
+ "del-cli": "^7.0.0",
60
+ "edge.js": "^6.3.0",
61
+ "eslint": "^9.39.1",
62
+ "ioredis": "^5.8.2",
63
63
  "knex": "^3.1.0",
64
- "luxon": "^3.6.1",
65
- "mysql2": "^3.14.1",
66
- "p-event": "^6.0.1",
67
- "pg": "^8.16.0",
68
- "prettier": "^3.5.3",
69
- "release-it": "^19.0.3",
70
- "ts-node-maintained": "^10.9.5",
71
- "tsup": "^8.5.0",
72
- "typescript": "~5.8.3"
64
+ "luxon": "^3.7.2",
65
+ "mysql2": "^3.15.3",
66
+ "p-event": "^7.0.1",
67
+ "pg": "^8.16.3",
68
+ "prettier": "^3.7.4",
69
+ "release-it": "^19.0.6",
70
+ "tsup": "^8.5.1",
71
+ "typescript": "~5.9.3"
73
72
  },
74
73
  "dependencies": {
75
- "bentocache": "^1.4.0"
74
+ "bentocache": "^1.5.0"
76
75
  },
77
76
  "peerDependencies": {
78
- "@adonisjs/assembler": "^7.0.0",
79
- "@adonisjs/core": "^6.2.0",
80
- "@adonisjs/lucid": "^20.0.0 || ^21.0.0",
81
- "@adonisjs/redis": "^8.0.0 || ^9.0.0"
77
+ "@adonisjs/assembler": "^8.0.0-next.19",
78
+ "@adonisjs/core": "^7.0.0-next.13",
79
+ "@adonisjs/lucid": "^22.0.0-next.1",
80
+ "@adonisjs/redis": "^10.0.0-next.1"
82
81
  },
83
82
  "peerDependenciesMeta": {
84
83
  "@adonisjs/redis": {
@@ -151,14 +150,16 @@
151
150
  "src/types.ts",
152
151
  "providers/cache_provider.ts",
153
152
  "services/main.ts",
154
- "commands/cache_clear.ts"
153
+ "commands/cache_clear.ts",
154
+ "commands/cache_delete.ts",
155
+ "commands/cache_prune.ts"
155
156
  ],
156
157
  "outDir": "./build",
157
158
  "clean": true,
158
159
  "format": "esm",
159
160
  "dts": false,
160
- "sourcemap": true,
161
+ "sourcemap": false,
161
162
  "target": "esnext"
162
163
  },
163
- "packageManager": "pnpm@10.12.1"
164
+ "packageManager": "pnpm@10.24.0"
164
165
  }
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../commands/cache_clear.ts"],"sourcesContent":["/*\n * @adonisjs/cache\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { args, BaseCommand, flags } from '@adonisjs/core/ace'\n\nimport { CacheService } from '../src/types.js'\nimport { CommandOptions } from '@adonisjs/core/types/ace'\n\nexport default class CacheClear extends BaseCommand {\n static commandName = 'cache:clear'\n static description = 'Clear the application cache'\n static options: CommandOptions = {\n startApp: true,\n }\n\n /**\n * Choose a custom cache store to clear. Otherwise, we use the\n * default one\n */\n @args.string({ description: 'Define a custom cache store to clear', required: false })\n declare store: string\n\n /**\n * Optionally select a namespace to clear. Defaults to the whole cache.\n */\n @flags.string({ description: 'Select a cache namespace to clear', alias: 'n' })\n declare namespace: string\n\n /**\n * Optionally specify tags to invalidate. Can be used multiple times.\n */\n @flags.array({ description: 'Specify tags to invalidate', alias: 't' })\n declare tags: string[]\n\n /**\n * Prompts to take consent when clearing the cache in production\n */\n async #takeProductionConsent(): Promise<boolean> {\n const question = 'You are in production environment. Want to continue clearing the cache?'\n try {\n return await this.prompt.confirm(question)\n } catch (error) {\n return false\n }\n }\n\n /**\n * Check if the given cache exist\n */\n #cacheExists(cache: CacheService, cacheName: string) {\n try {\n cache.use(cacheName)\n return true\n } catch (error) {\n return false\n }\n }\n\n /**\n * Handle command\n */\n async run() {\n const cache = await this.app.container.make('cache.manager')\n this.store = this.store || cache.defaultStoreName\n\n /**\n * Exit if cache store doesn't exist\n */\n if (!this.#cacheExists(cache, this.store)) {\n this.logger.error(\n `\"${this.store}\" is not a valid cache store. Double check config/cache.ts file`\n )\n this.exitCode = 1\n return\n }\n\n /**\n * Validate that namespace and tags are not used together\n */\n if (this.namespace && this.tags && this.tags.length > 0) {\n this.logger.error(\n 'Cannot use --namespace and --tags options together. Please choose one or the other.'\n )\n this.exitCode = 1\n return\n }\n\n /**\n * Take consent when clearing the cache in production\n */\n if (this.app.inProduction) {\n const shouldClear = await this.#takeProductionConsent()\n if (!shouldClear) return\n }\n\n /**\n * Finally clear the cache\n */\n const cacheHandler = cache.use(this.store)\n\n if (this.tags && this.tags.length > 0) {\n await cacheHandler.deleteByTag({ tags: this.tags })\n this.logger.success(\n `Invalidated tags [${this.tags.join(', ')}] for \"${this.store}\" cache successfully`\n )\n } else if (this.namespace) {\n await cacheHandler.namespace(this.namespace).clear()\n this.logger.success(\n `Cleared namespace \"${this.namespace}\" for \"${this.store}\" cache successfully`\n )\n } else {\n await cacheHandler.clear()\n this.logger.success(`Cleared \"${this.store}\" cache successfully`)\n }\n }\n}\n"],"mappings":";;;;;AASA,SAAS,MAAM,aAAa,aAAa;AAKzC,IAAqB,aAArB,cAAwC,YAAY;AAAA,EAClD,OAAO,cAAc;AAAA,EACrB,OAAO,cAAc;AAAA,EACrB,OAAO,UAA0B;AAAA,IAC/B,UAAU;AAAA,EACZ;AAAA;AAAA;AAAA;AAAA,EAwBA,MAAM,yBAA2C;AAC/C,UAAM,WAAW;AACjB,QAAI;AACF,aAAO,MAAM,KAAK,OAAO,QAAQ,QAAQ;AAAA,IAC3C,SAAS,OAAO;AACd,aAAO;AAAA,IACT;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,aAAa,OAAqB,WAAmB;AACnD,QAAI;AACF,YAAM,IAAI,SAAS;AACnB,aAAO;AAAA,IACT,SAAS,OAAO;AACd,aAAO;AAAA,IACT;AAAA,EACF;AAAA;AAAA;AAAA;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EAAE,aAAa,8BAA8B,OAAO,IAAI,CAAC;AAAA,GAvBnD,WAwBX;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../index.ts","../src/store.ts","../stubs/main.ts","../configure.ts","../src/define_config.ts","../src/drivers.ts"],"sourcesContent":["/*\n * @adonisjs/cache\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nexport * from 'bentocache'\n\nexport { store } from './src/store.js'\nexport { configure } from './configure.js'\nexport { defineConfig } from './src/define_config.js'\nexport { drivers } from './src/drivers.js'\n","/*\n * @adonisjs/cache\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { bentostore } from 'bentocache'\nimport { configProvider } from '@adonisjs/core'\nimport type { ConfigProvider } from '@adonisjs/core/types'\nimport {\n RawCommonOptions,\n CreateDriverResult,\n L1CacheDriver,\n CreateBusDriverResult,\n L2CacheDriver,\n} from 'bentocache/types'\n\n/**\n * Create a new store\n */\nexport function store(options?: RawCommonOptions & { prefix?: string }) {\n return new Store(options)\n}\n\nexport class Store {\n #baseOptions: RawCommonOptions & { prefix?: string } = {}\n #l1?: ConfigProvider<CreateDriverResult<L1CacheDriver>>\n #l2?: ConfigProvider<CreateDriverResult<L2CacheDriver>>\n #bus?: ConfigProvider<CreateBusDriverResult>\n\n constructor(baseOptions: RawCommonOptions & { prefix?: string } = {}) {\n this.#baseOptions = baseOptions\n }\n\n /**\n * Add a L1 layer to your store. This is usually a memory driver\n * for fast access purposes.\n */\n useL1Layer(driver: ConfigProvider<CreateDriverResult<L1CacheDriver>>) {\n this.#l1 = driver\n return this\n }\n\n /**\n * Add a L2 layer to your store. This is usually something\n * distributed like Redis, DynamoDB, Sql database, etc.\n */\n useL2Layer(driver: ConfigProvider<CreateDriverResult<L2CacheDriver>>) {\n this.#l2 = driver\n return this\n }\n\n /**\n * Add a bus to your store. It will be used to synchronize L1 layers between\n * different instances of your application.\n */\n useBus(bus: ConfigProvider<CreateBusDriverResult>) {\n this.#bus = bus\n return this\n }\n\n /**\n * Create a config provider for the store\n */\n entry() {\n return configProvider.create(async (app) => {\n const storeInstance = bentostore(this.#baseOptions)\n\n if (this.#l1) storeInstance.useL1Layer(await this.#l1?.resolver(app))\n if (this.#l2) storeInstance.useL2Layer(await this.#l2?.resolver(app))\n if (this.#bus) storeInstance.useBus(await this.#bus?.resolver(app))\n\n return storeInstance\n })\n }\n}\n","/*\n * @adonisjs/cache\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { dirname } from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nexport const stubsRoot = dirname(fileURLToPath(import.meta.url))\n","/*\n * @adonisjs/cache\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport type Configure from '@adonisjs/core/commands/configure'\n\nimport { stubsRoot } from './stubs/main.js'\n\nconst DRIVERS = ['redis', 'file', 'database', 'dynamodb'] as const\nconst DRIVERS_INFO: {\n [K in (typeof DRIVERS)[number]]: {\n envVars?: Record<string, number | string>\n envValidations?: Record<string, string>\n }\n} = {\n file: {},\n redis: {},\n database: {},\n dynamodb: {\n envValidations: {\n AWS_ACCESS_KEY_ID: `Env.schema.string()`,\n AWS_SECRET_ACCESS_KEY: `Env.schema.string()`,\n AWS_REGION: `Env.schema.string()`,\n DYNAMODB_ENDPOINT: `Env.schema.string()`,\n },\n envVars: {\n AWS_ACCESS_KEY_ID: '',\n AWS_SECRET_ACCESS_KEY: '',\n AWS_REGION: '',\n DYNAMODB_ENDPOINT: '',\n },\n },\n}\n\n/**\n * Configures the package\n */\nexport async function configure(command: Configure) {\n const driver = await command.prompt.choice(\n 'Select the cache driver you plan to use',\n ['redis', 'file', 'database', 'dynamodb'],\n {\n hint: 'You can always change it later',\n }\n )\n\n const codemods = await command.createCodemods()\n\n /**\n * Publish provider\n */\n await codemods.updateRcFile((rcFile) => {\n rcFile.addProvider('@adonisjs/cache/cache_provider').addCommand('@adonisjs/cache/commands')\n })\n\n const { envVars, envValidations } = DRIVERS_INFO[driver]\n\n /**\n * Define environment variables\n */\n if (envVars) {\n await codemods.defineEnvVariables(envVars)\n }\n\n /**\n * Define environment validations\n */\n if (envValidations) {\n await codemods.defineEnvValidations({ variables: envValidations })\n }\n\n /**\n * Publish config\n */\n await codemods.makeUsingStub(stubsRoot, 'config.stub', { driver: driver })\n}\n","/*\n * @adonisjs/cache\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { Store } from './store.js'\nimport { CacheOptions } from './types.js'\n\n/**\n * Define cache configuration\n */\nexport function defineConfig<KnownCaches extends Record<string, Store>>(\n config: CacheOptions & {\n default: keyof KnownCaches\n stores: KnownCaches\n }\n) {\n return config\n}\n","/*\n * @adonisjs/cache\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\n/// <reference types=\"@adonisjs/redis/redis_provider\" />\n/// <reference types=\"@adonisjs/lucid/database_provider\" />\n\nimport { configProvider } from '@adonisjs/core'\nimport type { RedisConnection } from '@adonisjs/redis'\nimport type { ConfigProvider } from '@adonisjs/core/types'\nimport type { RedisConnections } from '@adonisjs/redis/types'\nimport {\n MemoryConfig,\n CreateDriverResult,\n L1CacheDriver,\n L2CacheDriver,\n CreateBusDriverResult,\n DynamoDBConfig,\n FileConfig,\n KyselyConfig,\n OrchidConfig,\n} from 'bentocache/types'\nimport { RuntimeException } from '@adonisjs/core/exceptions'\n\n/**\n * Different drivers supported by the cache module\n */\nexport const drivers: {\n memory: (config?: MemoryConfig) => ConfigProvider<CreateDriverResult<L1CacheDriver>>\n redis: (config: {\n connectionName?: keyof RedisConnections\n }) => ConfigProvider<CreateDriverResult<L2CacheDriver>>\n redisBus: (config: {\n connectionName?: keyof RedisConnections\n }) => ConfigProvider<CreateBusDriverResult>\n database: (config?: {\n connectionName?: string\n }) => ConfigProvider<CreateDriverResult<L2CacheDriver>>\n dynamodb: (config: DynamoDBConfig) => ConfigProvider<CreateDriverResult<L2CacheDriver>>\n file: (config: FileConfig) => ConfigProvider<CreateDriverResult<L2CacheDriver>>\n kysely: (config: KyselyConfig) => ConfigProvider<CreateDriverResult<L2CacheDriver>>\n orchid: (config: OrchidConfig) => ConfigProvider<CreateDriverResult<L2CacheDriver>>\n} = {\n /**\n * Redis driver for L2 layer\n * You must install @adonisjs/redis to use this driver\n */\n redis(config) {\n return configProvider.create(async (app) => {\n const redis = await app.container.make('redis')\n const { redisDriver } = await import('bentocache/drivers/redis')\n\n const redisConnection = redis.connection(config.connectionName) as any as RedisConnection\n return redisDriver({ connection: redisConnection.ioConnection })\n })\n },\n\n /**\n * Redis driver for the sync bus\n * You must install @adonisjs/redis to use this driver\n */\n redisBus(config) {\n return configProvider.create(async (app) => {\n const redis = await app.container.make('redis')\n const { redisBusDriver } = await import('bentocache/drivers/redis')\n\n const redisConnection = redis.connection(config.connectionName) as any as RedisConnection\n return redisBusDriver({ connection: redisConnection.ioConnection.options })\n })\n },\n\n /**\n * Memory driver for L1 layer\n */\n memory(config) {\n return configProvider.create(async () => {\n const { memoryDriver } = await import('bentocache/drivers/memory')\n return memoryDriver(config)\n })\n },\n\n /**\n * Database driver for L2 layer\n * You must install @adonisjs/lucid to use this driver\n */\n database(config) {\n return configProvider.create(async (app) => {\n const db = await app.container.make('lucid.db')\n const connectionName = config?.connectionName || db.primaryConnectionName\n const connection = db.manager.get(connectionName)\n\n /**\n * Throw error when mentioned connection is not specified\n * in the database file\n */\n if (!connection) {\n throw new RuntimeException(\n `Invalid connection name \"${connectionName}\" referenced by \"config/cache.ts\" file. First register the connection inside \"config/database.ts\" file`\n )\n }\n\n const { knexDriver } = await import('bentocache/drivers/knex')\n return knexDriver({ connection: db.connection(connectionName).getWriteClient() })\n })\n },\n\n /**\n * DynamoDB driver for L2 layer\n * You must install @aws-sdk/client-dynamodb to use this driver\n */\n dynamodb(config) {\n return configProvider.create(async () => {\n const { dynamoDbDriver } = await import('bentocache/drivers/dynamodb')\n return dynamoDbDriver(config)\n })\n },\n\n /**\n * File driver for L2 layer\n */\n file(config) {\n return configProvider.create(async () => {\n const { fileDriver } = await import('bentocache/drivers/file')\n return fileDriver(config)\n })\n },\n\n /**\n * Kysely driver for L2 layer\n */\n kysely(config) {\n return configProvider.create(async () => {\n const { kyselyDriver } = await import('bentocache/drivers/kysely')\n return kyselyDriver(config)\n })\n },\n\n /**\n * Orchid driver for L2 layer\n */\n orchid(config) {\n return configProvider.create(async () => {\n const { orchidDriver } = await import('bentocache/drivers/orchid')\n return orchidDriver(config)\n })\n },\n}\n"],"mappings":";;;AASA,cAAc;;;ACAd,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB;AAaxB,SAAS,MAAM,SAAkD;AACtE,SAAO,IAAI,MAAM,OAAO;AAC1B;AAEO,IAAM,QAAN,MAAY;AAAA,EACjB,eAAuD,CAAC;AAAA,EACxD;AAAA,EACA;AAAA,EACA;AAAA,EAEA,YAAY,cAAsD,CAAC,GAAG;AACpE,SAAK,eAAe;AAAA,EACtB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,WAAW,QAA2D;AACpE,SAAK,MAAM;AACX,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,WAAW,QAA2D;AACpE,SAAK,MAAM;AACX,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO,KAA4C;AACjD,SAAK,OAAO;AACZ,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,QAAQ;AACN,WAAO,eAAe,OAAO,OAAO,QAAQ;AAC1C,YAAM,gBAAgB,WAAW,KAAK,YAAY;AAElD,UAAI,KAAK,IAAK,eAAc,WAAW,MAAM,KAAK,KAAK,SAAS,GAAG,CAAC;AACpE,UAAI,KAAK,IAAK,eAAc,WAAW,MAAM,KAAK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YAAY,GAAG,WAAW,cAAc,EAAE,eAAe,EAAE,CAAC;AAAA,IAClF,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAS,QAAQ;AACf,WAAOA,gBAAe,OAAO,YAAY;AACvC,YAAM,EAAE,eAAe,IAAI,MAAM,OAAO,6BAA6B;AACrE,aAAO,eAAe,MAAM;AAAA,IAC9B,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA,EAKA,KAAK,QAAQ;AACX,WAAOA,gBAAe,OAAO,YAAY;AACvC,YAAM,EAAE,WAAW,IAAI,MAAM,OAAO,yBAAyB;AAC7D,aAAO,WAAW,MAAM;AAAA,IAC1B,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,QAAQ;AACb,WAAOA,gBAAe,OAAO,YAAY;AACvC,YAAM,EAAE,aAAa,IAAI,MAAM,OAAO,2BAA2B;AACjE,aAAO,aAAa,MAAM;AAAA,IAC5B,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,QAAQ;AACb,WAAOA,gBAAe,OAAO,YAAY;AACvC,YAAM,EAAE,aAAa,IAAI,MAAM,OAAO,2BAA2B;AACjE,aAAO,aAAa,MAAM;AAAA,IAC5B,CAAC;AAAA,EACH;AACF;","names":["configProvider"]}
@@ -1 +0,0 @@
1
- {"inputs":{"src/store.ts":{"bytes":2107,"imports":[{"path":"bentocache","kind":"import-statement","external":true},{"path":"@adonisjs/core","kind":"import-statement","external":true},{"path":"bentocache/types","kind":"import-statement","external":true}],"format":"esm"},"stubs/main.ts":{"bytes":319,"imports":[{"path":"path","kind":"import-statement","external":true},{"path":"url","kind":"import-statement","external":true}],"format":"esm"},"configure.ts":{"bytes":1883,"imports":[{"path":"stubs/main.ts","kind":"import-statement","original":"./stubs/main.js"}],"format":"esm"},"src/define_config.ts":{"bytes":473,"imports":[{"path":"./store.js","kind":"import-statement","external":true},{"path":"./types.js","kind":"import-statement","external":true}],"format":"esm"},"src/drivers.ts":{"bytes":4713,"imports":[{"path":"@adonisjs/core","kind":"import-statement","external":true},{"path":"bentocache/types","kind":"import-statement","external":true},{"path":"@adonisjs/core/exceptions","kind":"import-statement","external":true},{"path":"bentocache/drivers/redis","kind":"dynamic-import","external":true},{"path":"bentocache/drivers/redis","kind":"dynamic-import","external":true},{"path":"bentocache/drivers/memory","kind":"dynamic-import","external":true},{"path":"bentocache/drivers/knex","kind":"dynamic-import","external":true},{"path":"bentocache/drivers/dynamodb","kind":"dynamic-import","external":true},{"path":"bentocache/drivers/file","kind":"dynamic-import","external":true},{"path":"bentocache/drivers/kysely","kind":"dynamic-import","external":true},{"path":"bentocache/drivers/orchid","kind":"dynamic-import","external":true}],"format":"esm"},"index.ts":{"bytes":383,"imports":[{"path":"bentocache","kind":"import-statement","external":true},{"path":"src/store.ts","kind":"import-statement","original":"./src/store.js"},{"path":"configure.ts","kind":"import-statement","original":"./configure.js"},{"path":"src/define_config.ts","kind":"import-statement","original":"./src/define_config.js"},{"path":"src/drivers.ts","kind":"import-statement","original":"./src/drivers.js"}],"format":"esm"},"commands/cache_clear.ts":{"bytes":3317,"imports":[{"path":"@adonisjs/core/ace","kind":"import-statement","external":true},{"path":"../src/types.js","kind":"import-statement","external":true},{"path":"@adonisjs/core/types/ace","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/bindings/repl.ts":{"bytes":910,"imports":[],"format":"esm"},"src/debug.ts":{"bytes":256,"imports":[{"path":"util","kind":"import-statement","external":true}],"format":"esm"},"src/bindings/edge.ts":{"bytes":474,"imports":[{"path":"src/debug.ts","kind":"import-statement","original":"../debug.js"},{"path":"../types.js","kind":"import-statement","external":true},{"path":"edge.js","kind":"dynamic-import","external":true}],"format":"esm"},"providers/cache_provider.ts":{"bytes":3079,"imports":[{"path":"../index.js","kind":"import-statement","external":true},{"path":"src/bindings/repl.ts","kind":"import-statement","original":"../src/bindings/repl.js"},{"path":"src/bindings/edge.ts","kind":"import-statement","original":"../src/bindings/edge.js"},{"path":"bentocache","kind":"dynamic-import","external":true}],"format":"esm"},"services/main.ts":{"bytes":476,"imports":[{"path":"@adonisjs/core/services/app","kind":"import-statement","external":true}],"format":"esm"},"src/types.ts":{"bytes":1047,"imports":[{"path":"bentocache/types","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"build/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":13928},"build/index.js":{"imports":[{"path":"build/chunk-EUXUH3YW.js","kind":"import-statement"},{"path":"bentocache","kind":"import-statement","external":true},{"path":"bentocache","kind":"import-statement","external":true},{"path":"@adonisjs/core","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"url","kind":"import-statement","external":true},{"path":"@adonisjs/core","kind":"import-statement","external":true},{"path":"@adonisjs/core/exceptions","kind":"import-statement","external":true},{"path":"bentocache/drivers/redis","kind":"dynamic-import","external":true},{"path":"bentocache/drivers/redis","kind":"dynamic-import","external":true},{"path":"bentocache/drivers/memory","kind":"dynamic-import","external":true},{"path":"bentocache/drivers/knex","kind":"dynamic-import","external":true},{"path":"bentocache/drivers/dynamodb","kind":"dynamic-import","external":true},{"path":"bentocache/drivers/file","kind":"dynamic-import","external":true},{"path":"bentocache/drivers/kysely","kind":"dynamic-import","external":true},{"path":"bentocache/drivers/orchid","kind":"dynamic-import","external":true}],"exports":["configure","defineConfig","drivers","store"],"entryPoint":"index.ts","inputs":{"index.ts":{"bytesInOutput":28},"src/store.ts":{"bytesInOutput":1304},"stubs/main.ts":{"bytesInOutput":126},"configure.ts":{"bytesInOutput":1170},"src/define_config.ts":{"bytesInOutput":51},"src/drivers.ts":{"bytesInOutput":3081}},"bytes":5959},"build/commands/cache_clear.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":5125},"build/commands/cache_clear.js":{"imports":[{"path":"build/chunk-EUXUH3YW.js","kind":"import-statement"},{"path":"@adonisjs/core/ace","kind":"import-statement","external":true}],"exports":["default"],"entryPoint":"commands/cache_clear.ts","inputs":{"commands/cache_clear.ts":{"bytesInOutput":2556}},"bytes":2678},"build/providers/cache_provider.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":6765},"build/providers/cache_provider.js":{"imports":[{"path":"build/chunk-EUXUH3YW.js","kind":"import-statement"},{"path":"util","kind":"import-statement","external":true},{"path":"edge.js","kind":"dynamic-import","external":true},{"path":"bentocache","kind":"dynamic-import","external":true}],"exports":["default"],"entryPoint":"providers/cache_provider.ts","inputs":{"src/bindings/repl.ts":{"bytesInOutput":443},"src/debug.ts":{"bytesInOutput":81},"src/bindings/edge.ts":{"bytesInOutput":211},"providers/cache_provider.ts":{"bytesInOutput":1658}},"bytes":2562},"build/services/main.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":718},"build/services/main.js":{"imports":[{"path":"build/chunk-EUXUH3YW.js","kind":"import-statement"},{"path":"@adonisjs/core/services/app","kind":"import-statement","external":true}],"exports":["default"],"entryPoint":"services/main.ts","inputs":{"services/main.ts":{"bytesInOutput":146}},"bytes":229},"build/chunk-EUXUH3YW.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"build/chunk-EUXUH3YW.js":{"imports":[],"exports":["__decorateClass"],"inputs":{},"bytes":524},"build/src/types.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":1214},"build/src/types.js":{"imports":[{"path":"bentocache/types","kind":"import-statement","external":true}],"exports":[],"entryPoint":"src/types.ts","inputs":{"src/types.ts":{"bytesInOutput":34}},"bytes":50}}}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/bindings/repl.ts","../../src/debug.ts","../../src/bindings/edge.ts","../../providers/cache_provider.ts"],"sourcesContent":["/*\n * @adonisjs/cache\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport type { Repl } from '@adonisjs/core/repl'\nimport type { ApplicationService } from '@adonisjs/core/types'\n\n/**\n * Helper to define REPL state\n */\nfunction setupReplState(repl: any, key: string, value: any) {\n repl.server.context[key] = value\n repl.notify(\n `Loaded ${key} module. You can access it using the \"${repl.colors.underline(key)}\" variable`\n )\n}\n\n/**\n * Define REPL bindings\n */\nexport function defineReplBindings(app: ApplicationService, Repl: Repl) {\n /**\n * Load cache provider to the cache property\n */\n Repl.addMethod(\n 'loadCache',\n async (repl) => setupReplState(repl, 'cache', await app.container.make('cache.manager')),\n { description: 'Load cache provider to the \"cache\" property' }\n )\n}\n","/*\n * @adonisjs/drive\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { debuglog } from 'node:util'\n\nexport default debuglog('adonisjs:cache')\n","/*\n * @adonisjs/cache\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport debug from '../debug.js'\nimport { CacheService } from '../types.js'\n\nexport async function registerViewBindings(manager: CacheService) {\n const edge = await import('edge.js')\n debug('detected edge installation. Registering cache global helpers')\n\n edge.default.global('cache', manager)\n}\n","/*\n * @adonisjs/cache\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport type { ApplicationService } from '@adonisjs/core/types'\n\nimport { defineConfig } from '../index.js'\nimport type { CacheEvents } from 'bentocache/types'\nimport type { CacheService } from '../src/types.js'\nimport { defineReplBindings } from '../src/bindings/repl.js'\nimport { registerViewBindings } from '../src/bindings/edge.js'\n\n/**\n * Extend Adonis.js types to include cache\n */\ndeclare module '@adonisjs/core/types' {\n /**\n * Adding cache type to the application container\n */\n export interface ContainerBindings {\n 'cache.manager': CacheService\n }\n\n /**\n * Add cache events to the application events list\n */\n export interface EventsList {\n 'cache:cleared': CacheEvents['cache:cleared']\n 'cache:deleted': CacheEvents['cache:deleted']\n 'cache:hit': CacheEvents['cache:hit']\n 'cache:miss': CacheEvents['cache:miss']\n 'cache:written': CacheEvents['cache:written']\n 'bus:message:published': CacheEvents['bus:message:published']\n 'bus:message:received': CacheEvents['bus:message:received']\n }\n}\n\n/**\n * Cache provider to register cache specific bindings\n */\nexport default class CacheProvider {\n constructor(protected app: ApplicationService) {}\n\n /**\n * Register the cache manager to the container\n */\n async #registerCacheManager() {\n const cacheConfig = this.app.config.get<ReturnType<typeof defineConfig>>('cache')\n\n this.app.container.singleton('cache.manager', async () => {\n const { BentoCache } = await import('bentocache')\n const emitter = await this.app.container.make('emitter')\n\n /**\n * Resolve all store config providers\n */\n const resolvedStores = Object.entries(cacheConfig.stores).map(async ([name, store]) => {\n return [name, await store.entry().resolver(this.app)]\n })\n\n return new BentoCache({\n ...cacheConfig,\n emitter: emitter as any,\n default: cacheConfig.default,\n stores: Object.fromEntries(await Promise.all(resolvedStores)),\n })\n })\n }\n\n /**\n * Register REPL bindings\n */\n async #registerReplBindings() {\n if (this.app.getEnvironment() !== 'repl') {\n return\n }\n\n const repl = await this.app.container.make('repl')\n defineReplBindings(this.app, repl)\n }\n\n /**\n * Register edge bindings\n */\n async #registerEdgeBindings() {\n if (!this.app.usingEdgeJS) return\n\n const manager = await this.app.container.make('cache.manager')\n await registerViewBindings(manager)\n }\n\n /**\n * Register bindings\n */\n async register() {\n await this.#registerCacheManager()\n await this.#registerReplBindings()\n await this.#registerEdgeBindings()\n }\n\n /**\n * Gracefully shutdown connections when app goes down\n */\n async shutdown() {\n try {\n const cache = await this.app.container.make('cache.manager')\n await cache.disconnectAll()\n } catch (_e) {\n // Ignore errors\n }\n }\n}\n"],"mappings":";;;AAeA,SAAS,eAAe,MAAW,KAAa,OAAY;AAC1D,OAAK,OAAO,QAAQ,GAAG,IAAI;AAC3B,OAAK;AAAA,IACH,UAAU,GAAG,yCAAyC,KAAK,OAAO,UAAU,GAAG,CAAC;AAAA,EAClF;AACF;AAKO,SAAS,mBAAmB,KAAyB,MAAY;AAItE,OAAK;AAAA,IACH;AAAA,IACA,OAAO,SAAS,eAAe,MAAM,SAAS,MAAM,IAAI,UAAU,KAAK,eAAe,CAAC;AAAA,IACvF,EAAE,aAAa,8C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U,KAAK,eAAe;AAC7D,UAAM,qBAAqB,OAAO;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,WAAW;AACf,UAAM,KAAK,sBAAsB;AACjC,UAAM,KAAK,sBAAsB;AACjC,UAAM,KAAK,sBAAsB;AAAA,EACnC;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,WAAW;AACf,QAAI;AACF,YAAM,QAAQ,MAAM,KAAK,IAAI,UAAU,KAAK,eAAe;AAC3D,YAAM,MAAM,cAAc;AAAA,IAC5B,SAAS,IAAI;AAAA,IAEb;AAAA,EACF;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../services/main.ts"],"sourcesContent":["/*\n * @adonisjs/cache\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport type { CacheService } from '../src/types.js'\nimport app from '@adonisjs/core/services/app'\n\nlet cache: CacheService\n\n/**\n * Returns a singleton instance of the Cache manager\n */\nawait app.booted(async () => {\n cache = await app.container.make('cache.manager')\n})\n\nexport { cache as default }\n"],"mappings":";;;AAUA,OAAO,SAAS;AAEhB,IAAI;AAKJ,MAAM,IAAI,OAAO,YAAY;AAC3B,UAAQ,MAAM,IAAI,UAAU,KAAK,eAAe;AAClD,CAAC;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/types.ts"],"sourcesContent":["/*\n * @adonisjs/cache\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nexport * from 'bentocache/types'\n\nimport type { BentoCache, bentostore } from 'bentocache'\nimport type { RawBentoCacheOptions } from 'bentocache/types'\n\nimport type { store } from './store.js'\n\n/**\n * The options accepted by the cache module\n */\nexport type CacheOptions = Omit<RawBentoCacheOptions, 'logger' | 'emitter'>\n\n/**\n * Infer the stores from the user config\n */\nexport type InferStores<T extends { stores: Record<string, ReturnType<typeof store>> }> = {\n [K in keyof T['stores']]: any\n}\n\n/**\n * A list of known caches stores inferred from the user config\n * This interface must be extended in user-land\n */\nexport interface CacheStores {}\n\n/**\n * The cache service interface registered with the container\n */\nexport interface CacheService\n extends BentoCache<\n CacheStores extends Record<string, ReturnType<typeof bentostore>> ? CacheStores : never\n > {}\n"],"mappings":";AASA,cAAc;","names":[]}