@adonisjs/cache 1.0.0-6 → 1.0.1

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/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
  Cache module for AdonisJS built on top of BentoCache. Support multiples drivers, File, In-Memory, Redis, SQLs databases and more.
9
9
 
10
10
  ## Official Documentation
11
- The documentation is available on the [AdonisJS website](https://docs.adonisjs.com/guides/cache/introduction).
11
+ The documentation is available on the [AdonisJS website](https://docs.adonisjs.com/guides/digging-deeper/cache).
12
12
 
13
13
  ## Contributing
14
14
  One of the primary goals of AdonisJS is to have a vibrant community of users and contributors who believes in the principles of the framework.
@@ -21,8 +21,8 @@ In order to ensure that the AdonisJS community is welcoming to all, please revie
21
21
  ## License
22
22
  AdonisJS Lucid is open-sourced software licensed under the [MIT license](LICENSE.md).
23
23
 
24
- [gh-workflow-image]: https://img.shields.io/github/actions/workflow/status/adonisjs/cache/test.yml?style=for-the-badge
25
- [gh-workflow-url]: https://github.com/adonisjs/cache/actions/workflows/test.yml "Github action"
24
+ [gh-workflow-image]: https://img.shields.io/github/actions/workflow/status/adonisjs/cache/checks.yml?branch=1.x&style=for-the-badge
25
+ [gh-workflow-url]: https://github.com/adonisjs/cache/actions/workflows/checks.yml "Github action"
26
26
 
27
27
  [npm-image]: https://img.shields.io/npm/v/@adonisjs/cache/latest.svg?style=for-the-badge&logo=npm
28
28
  [npm-url]: https://www.npmjs.com/package/@adonisjs/cache/v/latest "npm"
@@ -0,0 +1,15 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __decorateClass = (decorators, target, key, kind) => {
4
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
+ if (decorator = decorators[i])
7
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
+ if (kind && result) __defProp(target, key, result);
9
+ return result;
10
+ };
11
+
12
+ export {
13
+ __decorateClass
14
+ };
15
+ //# sourceMappingURL=chunk-EUXUH3YW.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,62 @@
1
+ import {
2
+ __decorateClass
3
+ } from "../chunk-EUXUH3YW.js";
4
+
5
+ // commands/cache_clear.ts
6
+ import { BaseCommand, flags } from "@adonisjs/core/ace";
7
+ var CacheClear = class extends BaseCommand {
8
+ static commandName = "cache:clear";
9
+ static description = "Clear the application cache";
10
+ static options = {
11
+ startApp: true
12
+ };
13
+ /**
14
+ * Prompts to take consent when clearing the cache in production
15
+ */
16
+ async #takeProductionConsent() {
17
+ const question = "You are in production environment. Want to continue clearing the cache?";
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 shouldClear = await this.#takeProductionConsent();
50
+ if (!shouldClear) return;
51
+ }
52
+ await cache.use(this.store).clear();
53
+ this.logger.success(`Cleared "${this.store}" cache successfully`);
54
+ }
55
+ };
56
+ __decorateClass([
57
+ flags.string({ description: "Define a custom cache store to clear", alias: "s" })
58
+ ], CacheClear.prototype, "store", 2);
59
+ export {
60
+ CacheClear as default
61
+ };
62
+ //# sourceMappingURL=cache_clear.js.map
@@ -0,0 +1 @@
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 { 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 @flags.string({ description: 'Define a custom cache store to clear', alias: 's' })\n declare store: 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 exists\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 * 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 await cache.use(this.store).clear()\n this.logger.success(`Cleared \"${this.store}\" cache successfully`)\n }\n}\n"],"mappings":";;;;;AASA,SAAS,aAAa,aAAa;AAKnC,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,EAYA,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;AAAA,EAKA,MAAM,MAAM;AACV,UAAM,QAAQ,MAAM,KAAK,IAAI,UAAU,KAAK,eAAe;AAC3D,SAAK,QAAQ,KAAK,SAAS,MAAM;AAKjC,QAAI,CAAC,KAAK,aAAa,OAAO,KAAK,KAAK,GAAG;AACzC,WAAK,OAAO;AAAA,QACV,IAAI,KAAK,KAAK;AAAA,MAChB;AACA,WAAK,WAAW;AAChB;AAAA,IACF;AAKA,QAAI,KAAK,IAAI,cAAc;AACzB,YAAM,cAAc,MAAM,KAAK,uBAAuB;AACtD,UAAI,CAAC,YAAa;AAAA,IACpB;AAKA,UAAM,MAAM,IAAI,KAAK,KAAK,EAAE,MAAM;AAClC,SAAK,OAAO,QAAQ,YAAY,KAAK,KAAK,sBAAsB;AAAA,EAClE;AACF;AA1DU;AAAA,EADP,MAAM,OAAO,EAAE,aAAa,wCAAwC,OAAO,IAAI,CAAC;AAAA,GAX9D,WAYX;","names":[]}
@@ -1 +1 @@
1
- {"commands":[],"version":1}
1
+ {"commands":[{"commandName":"cache:clear","description":"Clear the application cache","help":"","namespace":"cache","aliases":[],"flags":[{"name":"store","flagName":"store","required":false,"type":"string","description":"Define a custom cache store to clear","alias":"s"}],"args":[],"options":{"startApp":true},"filePath":"cache_clear.js"}],"version":1}
@@ -0,0 +1,48 @@
1
+ {{{
2
+ exports({ to: app.configPath('cache.ts') })
3
+ }}}
4
+ import env from '#start/env'
5
+ {{#if driver === 'file'}}
6
+ import app from '@adonisjs/core/services/app'
7
+ {{/if}}
8
+ import { defineConfig, store, drivers } from '@adonisjs/cache'
9
+
10
+ const cacheConfig = defineConfig({
11
+ default: 'default',
12
+
13
+ stores: {
14
+ memoryOnly: store().useL1Layer(drivers.memory()),
15
+
16
+ default: store()
17
+ .useL1Layer(drivers.memory())
18
+ {{#if driver === 'database'}}
19
+ .useL2Layer(drivers.database({
20
+ connectionName: 'primary',
21
+ }))
22
+ {{#elif driver === 'redis'}}
23
+ .useL2Layer(drivers.redis({
24
+ connectionName: 'main',
25
+ }))
26
+ {{#elif driver === 'file'}}
27
+ .useL2Layer(drivers.file({
28
+ directory: app.tmpPath('cache')
29
+ }))
30
+ {{#elif driver === 'dynamodb'}}
31
+ .useL2Layer(drivers.dynamodb({
32
+ table: { name: 'cache' },
33
+ credentials: {
34
+ accessKeyId: env.get('AWS_ACCESS_KEY_ID'),
35
+ secretAccessKey: env.get('AWS_SECRET_ACCESS_KEY')
36
+ },
37
+ region: env.get('AWS_REGION'),
38
+ endpoint: env.get('DYNAMODB_ENDPOINT')
39
+ }))
40
+ {{/if}}
41
+ }
42
+ })
43
+
44
+ export default cacheConfig
45
+
46
+ declare module '@adonisjs/cache/types' {
47
+ interface CacheStores extends InferStores<typeof cacheConfig> {}
48
+ }
package/build/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { errors } from 'bentocache';
1
+ export * from 'bentocache';
2
+ export { store } from './src/store.js';
2
3
  export { configure } from './configure.js';
3
4
  export { defineConfig } from './src/define_config.js';
4
5
  export { drivers } from './src/drivers.js';
5
- export { store } from './src/store.js';
package/build/index.js CHANGED
@@ -1,5 +1,59 @@
1
+ import "./chunk-EUXUH3YW.js";
2
+
1
3
  // index.ts
2
- import { errors } from "bentocache";
4
+ export * from "bentocache";
5
+
6
+ // src/store.ts
7
+ import { bentostore } from "bentocache";
8
+ import { configProvider } from "@adonisjs/core";
9
+ function store(options) {
10
+ return new Store(options);
11
+ }
12
+ var Store = class {
13
+ #baseOptions = {};
14
+ #l1;
15
+ #l2;
16
+ #bus;
17
+ constructor(baseOptions = {}) {
18
+ this.#baseOptions = baseOptions;
19
+ }
20
+ /**
21
+ * Add a L1 layer to your store. This is usually a memory driver
22
+ * for fast access purposes.
23
+ */
24
+ useL1Layer(driver) {
25
+ this.#l1 = driver;
26
+ return this;
27
+ }
28
+ /**
29
+ * Add a L2 layer to your store. This is usually something
30
+ * distributed like Redis, DynamoDB, Sql database, etc.
31
+ */
32
+ useL2Layer(driver) {
33
+ this.#l2 = driver;
34
+ return this;
35
+ }
36
+ /**
37
+ * Add a bus to your store. It will be used to synchronize L1 layers between
38
+ * different instances of your application.
39
+ */
40
+ useBus(bus) {
41
+ this.#bus = bus;
42
+ return this;
43
+ }
44
+ /**
45
+ * Create a config provider for the store
46
+ */
47
+ entry() {
48
+ return configProvider.create(async (app) => {
49
+ const storeInstance = bentostore(this.#baseOptions);
50
+ if (this.#l1) storeInstance.useL1Layer(await this.#l1?.resolver(app));
51
+ if (this.#l2) storeInstance.useL2Layer(await this.#l2?.resolver(app));
52
+ if (this.#bus) storeInstance.useBus(await this.#bus?.resolver(app));
53
+ return storeInstance;
54
+ });
55
+ }
56
+ };
3
57
 
4
58
  // stubs/main.ts
5
59
  import { dirname } from "node:path";
@@ -9,7 +63,6 @@ var stubsRoot = dirname(fileURLToPath(import.meta.url));
9
63
  // configure.ts
10
64
  var DRIVERS_INFO = {
11
65
  file: {},
12
- memory: {},
13
66
  redis: {},
14
67
  database: {},
15
68
  dynamodb: {
@@ -30,21 +83,21 @@ var DRIVERS_INFO = {
30
83
  async function configure(command) {
31
84
  const driver = await command.prompt.choice(
32
85
  "Select the cache driver you plan to use",
33
- ["redis", "file", "memory", "database", "dynamodb"],
86
+ ["redis", "file", "database", "dynamodb"],
34
87
  {
35
88
  hint: "You can always change it later"
36
89
  }
37
90
  );
38
- const { envVars, envValidations } = DRIVERS_INFO[driver];
39
91
  const codemods = await command.createCodemods();
40
92
  await codemods.updateRcFile((rcFile) => {
41
93
  rcFile.addProvider("@adonisjs/cache/cache_provider").addCommand("@adonisjs/cache/commands");
42
94
  });
95
+ const { envVars, envValidations } = DRIVERS_INFO[driver];
43
96
  if (envVars) {
44
- codemods.defineEnvVariables(envVars);
97
+ await codemods.defineEnvVariables(envVars);
45
98
  }
46
99
  if (envValidations) {
47
- codemods.defineEnvValidations({ variables: envValidations });
100
+ await codemods.defineEnvValidations({ variables: envValidations });
48
101
  }
49
102
  await codemods.makeUsingStub(stubsRoot, "config.stub", { driver });
50
103
  }
@@ -55,14 +108,15 @@ function defineConfig(config) {
55
108
  }
56
109
 
57
110
  // src/drivers.ts
58
- import { configProvider } from "@adonisjs/core";
111
+ import { configProvider as configProvider2 } from "@adonisjs/core";
112
+ import { RuntimeException } from "@adonisjs/core/exceptions";
59
113
  var drivers = {
60
114
  /**
61
115
  * Redis driver for L2 layer
62
116
  * You must install @adonisjs/redis to use this driver
63
117
  */
64
118
  redis(config) {
65
- return configProvider.create(async (app) => {
119
+ return configProvider2.create(async (app) => {
66
120
  const redis = await app.container.make("redis");
67
121
  const { redisDriver } = await import("bentocache/drivers/redis");
68
122
  const redisConnection = redis.connection(config.connectionName);
@@ -74,7 +128,7 @@ var drivers = {
74
128
  * You must install @adonisjs/redis to use this driver
75
129
  */
76
130
  redisBus(config) {
77
- return configProvider.create(async (app) => {
131
+ return configProvider2.create(async (app) => {
78
132
  const redis = await app.container.make("redis");
79
133
  const { redisBusDriver } = await import("bentocache/drivers/redis");
80
134
  const redisConnection = redis.connection(config.connectionName);
@@ -85,7 +139,7 @@ var drivers = {
85
139
  * Memory driver for L1 layer
86
140
  */
87
141
  memory(config) {
88
- return configProvider.create(async () => {
142
+ return configProvider2.create(async () => {
89
143
  const { memoryDriver } = await import("bentocache/drivers/memory");
90
144
  return memoryDriver(config);
91
145
  });
@@ -95,25 +149,17 @@ var drivers = {
95
149
  * You must install @adonisjs/lucid to use this driver
96
150
  */
97
151
  database(config) {
98
- return configProvider.create(async (app) => {
152
+ return configProvider2.create(async (app) => {
99
153
  const db = await app.container.make("lucid.db");
100
154
  const connectionName = config?.connectionName || db.primaryConnectionName;
101
- const dialect = db.connection(connectionName).dialect.name;
102
- const supportedDialects = ["pg", "postgres", "mysql", "better-sqlite3", "sqlite3"];
103
- if (!supportedDialects.includes(dialect)) {
104
- throw new Error(`Unsupported dialect "${dialect}"`);
105
- }
106
- const rawConnection = db.getRawConnection(connectionName);
107
- if (!rawConnection?.connection?.client) {
108
- throw new Error(`Unable to get raw connection for "${connectionName}"`);
155
+ const connection = db.manager.get(connectionName);
156
+ if (!connection) {
157
+ throw new RuntimeException(
158
+ `Invalid connection name "${connectionName}" referenced by "config/cache.ts" file. First register the connection inside "config/database.ts" file`
159
+ );
109
160
  }
110
- const { default: knex } = await import("knex");
111
- const knexClient = knex({
112
- ...rawConnection.config,
113
- client: ["postgres", "pg"].includes(dialect) ? "pg" : dialect
114
- });
115
161
  const { knexDriver } = await import("bentocache/drivers/knex");
116
- return knexDriver({ connection: knexClient });
162
+ return knexDriver({ connection: db.connection(connectionName).getWriteClient() });
117
163
  });
118
164
  },
119
165
  /**
@@ -121,7 +167,7 @@ var drivers = {
121
167
  * You must install @aws-sdk/client-dynamodb to use this driver
122
168
  */
123
169
  dynamodb(config) {
124
- return configProvider.create(async () => {
170
+ return configProvider2.create(async () => {
125
171
  const { dynamoDbDriver } = await import("bentocache/drivers/dynamodb");
126
172
  return dynamoDbDriver(config);
127
173
  });
@@ -130,7 +176,7 @@ var drivers = {
130
176
  * File driver for L2 layer
131
177
  */
132
178
  file(config) {
133
- return configProvider.create(async () => {
179
+ return configProvider2.create(async () => {
134
180
  const { fileDriver } = await import("bentocache/drivers/file");
135
181
  return fileDriver(config);
136
182
  });
@@ -139,7 +185,7 @@ var drivers = {
139
185
  * Kysely driver for L2 layer
140
186
  */
141
187
  kysely(config) {
142
- return configProvider.create(async () => {
188
+ return configProvider2.create(async () => {
143
189
  const { kyselyDriver } = await import("bentocache/drivers/kysely");
144
190
  return kyselyDriver(config);
145
191
  });
@@ -148,69 +194,16 @@ var drivers = {
148
194
  * Orchid driver for L2 layer
149
195
  */
150
196
  orchid(config) {
151
- return configProvider.create(async () => {
197
+ return configProvider2.create(async () => {
152
198
  const { orchidDriver } = await import("bentocache/drivers/orchid");
153
199
  return orchidDriver(config);
154
200
  });
155
201
  }
156
202
  };
157
-
158
- // src/store.ts
159
- import { bentostore } from "bentocache";
160
- import { configProvider as configProvider2 } from "@adonisjs/core";
161
- function store(options) {
162
- return new Store(options);
163
- }
164
- var Store = class {
165
- #baseOptions = {};
166
- #l1;
167
- #l2;
168
- #bus;
169
- constructor(baseOptions = {}) {
170
- this.#baseOptions = baseOptions;
171
- }
172
- /**
173
- * Add a L1 layer to your store. This is usually a memory driver
174
- * for fast access purposes.
175
- */
176
- useL1Layer(driver) {
177
- this.#l1 = driver;
178
- return this;
179
- }
180
- /**
181
- * Add a L2 layer to your store. This is usually something
182
- * distributed like Redis, DynamoDB, Sql database, etc.
183
- */
184
- useL2Layer(driver) {
185
- this.#l2 = driver;
186
- return this;
187
- }
188
- /**
189
- * Add a bus to your store. It will be used to synchronize L1 layers between
190
- * different instances of your application.
191
- */
192
- useBus(bus) {
193
- this.#bus = bus;
194
- return this;
195
- }
196
- /**
197
- * Create a config provider for the store
198
- */
199
- entry() {
200
- return configProvider2.create(async (app) => {
201
- const storeInstance = bentostore(this.#baseOptions);
202
- if (this.#l1) storeInstance.useL1Layer(await this.#l1?.resolver(app));
203
- if (this.#l2) storeInstance.useL2Layer(await this.#l2?.resolver(app));
204
- if (this.#bus) storeInstance.useBus(await this.#bus?.resolver(app));
205
- return storeInstance;
206
- });
207
- }
208
- };
209
203
  export {
210
204
  configure,
211
205
  defineConfig,
212
206
  drivers,
213
- errors,
214
207
  store
215
208
  };
216
209
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../index.ts","../stubs/main.ts","../configure.ts","../src/define_config.ts","../src/drivers.ts","../src/store.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 { errors } from 'bentocache'\nexport { configure } from './configure.js'\n\nexport { defineConfig } from './src/define_config.js'\nexport { drivers } from './src/drivers.js'\nexport { store } from './src/store.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 { 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', 'memory', '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 memory: {},\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', 'memory', 'database', 'dynamodb'],\n {\n hint: 'You can always change it later',\n }\n )\n const { envVars, envValidations } = DRIVERS_INFO[driver]\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 /**\n * Define environment variables\n */\n if (envVars) {\n codemods.defineEnvVariables(envVars)\n }\n\n /**\n * Define environment validations\n */\n if (envValidations) {\n 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 DialectName,\n CreateBusDriverResult,\n DynamoDBConfig,\n FileConfig,\n KyselyConfig,\n OrchidConfig,\n} from 'bentocache/types'\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 dialect = db.connection(connectionName).dialect.name\n\n /**\n * We only support pg, mysql, better-sqlite3 and sqlite3 dialects for now\n */\n const supportedDialects = ['pg', 'postgres', 'mysql', 'better-sqlite3', 'sqlite3']\n if (!supportedDialects.includes(dialect)) {\n throw new Error(`Unsupported dialect \"${dialect}\"`)\n }\n\n /**\n * Get the knex connection for the given connection name\n */\n const rawConnection = db.getRawConnection(connectionName)\n if (!rawConnection?.connection?.client) {\n throw new Error(`Unable to get raw connection for \"${connectionName}\"`)\n }\n\n /**\n * Create the driver\n */\n const { default: knex } = await import('knex')\n const knexClient = knex({\n ...rawConnection.config,\n client: ['postgres', 'pg'].includes(dialect) ? 'pg' : (dialect as DialectName),\n })\n\n const { knexDriver } = await import('bentocache/drivers/knex')\n return knexDriver({ connection: knexClient })\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","/*\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"],"mappings":";AASA,SAAS,cAAc;;;ACAvB,SAAS,eAAe;AACxB,SAAS,qBAAqB;AAEvB,IAAM,YAAY,QAAQ,cAAc,YAAY,GAAG,CAAC;;;ACE/D,IAAM,eAKF;AAAA,EACF,MAAM,CAAC;AAAA,EACP,QAAQ,CAAC;AAAA,EACT,OAAO,CAAC;AAAA,EACR,UAAU,CAAC;AAAA,EACX,UAAU;AAAA,IACR,gBAAgB;AAAA,MACd,mBAAmB;AAAA,MACnB,uBAAuB;AAAA,MACvB,YAAY;AAAA,MACZ,mBAAmB;AAAA,IACrB;AAAA,IACA,SAAS;AAAA,MACP,mBAAmB;AAAA,MACnB,uBAAuB;AAAA,MACvB,YAAY;AAAA,MACZ,mBAAmB;AAAA,IACrB;AAAA,EACF;AACF;AAKA,eAAsB,UAAU,SAAoB;AAClD,QAAM,SAAS,MAAM,QAAQ,OAAO;AAAA,IAClC;AAAA,IACA,CAAC,SAAS,QAAQ,UAAU,YAAY,UAAU;AAAA,IAClD;AAAA,MACE,MAAM;AAAA,IACR;AAAA,EACF;AACA,QAAM,EAAE,SAAS,eAAe,IAAI,aAAa,MAAM;AAEvD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F;","names":["configProvider"]}
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,KAAK,SAAS,GAAG,CAAC;AACpE,UAAI,KAAK,KAAM,eAAc,OAAO,MAAM,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AAA,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 +1 @@
1
- {"inputs":{"stubs/main.ts":{"bytes":319,"imports":[{"path":"node:path","kind":"import-statement","external":true},{"path":"node:url","kind":"import-statement","external":true}],"format":"esm"},"configure.ts":{"bytes":1904,"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":5144,"imports":[{"path":"@adonisjs/core","kind":"import-statement","external":true},{"path":"bentocache/types","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":"knex","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"},"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"},"index.ts":{"bytes":392,"imports":[{"path":"bentocache","kind":"import-statement","external":true},{"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"},{"path":"src/store.ts","kind":"import-statement","original":"./src/store.js"}],"format":"esm"},"src/bindings/repl.ts":{"bytes":910,"imports":[],"format":"esm"},"src/debug.ts":{"bytes":256,"imports":[{"path":"node: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":2802,"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":14701},"build/index.js":{"imports":[{"path":"bentocache","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:url","kind":"import-statement","external":true},{"path":"@adonisjs/core","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":"knex","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},{"path":"bentocache","kind":"import-statement","external":true},{"path":"@adonisjs/core","kind":"import-statement","external":true}],"exports":["configure","defineConfig","drivers","errors","store"],"entryPoint":"index.ts","inputs":{"index.ts":{"bytesInOutput":37},"stubs/main.ts":{"bytesInOutput":136},"configure.ts":{"bytesInOutput":1182},"src/define_config.ts":{"bytesInOutput":51},"src/drivers.ts":{"bytesInOutput":3338},"src/store.ts":{"bytesInOutput":1324}},"bytes":6246},"build/providers/cache_provider.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":6302},"build/providers/cache_provider.js":{"imports":[{"path":"node: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":86},"src/bindings/edge.ts":{"bytesInOutput":211},"providers/cache_provider.ts":{"bytesInOutput":1403}},"bytes":2280},"build/services/main.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":716},"build/services/main.js":{"imports":[{"path":"@adonisjs/core/services/app","kind":"import-statement","external":true}],"exports":["default"],"entryPoint":"services/main.ts","inputs":{"services/main.ts":{"bytesInOutput":146}},"bytes":197},"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
+ {"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":"node:path","kind":"import-statement","external":true},{"path":"node: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":2109,"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":"node: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":"node:path","kind":"import-statement","external":true},{"path":"node: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":136},"configure.ts":{"bytesInOutput":1170},"src/define_config.ts":{"bytesInOutput":51},"src/drivers.ts":{"bytesInOutput":3081}},"bytes":5969},"build/commands/cache_clear.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":3255},"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":1531}},"bytes":1653},"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":"node: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":86},"src/bindings/edge.ts":{"bytesInOutput":211},"providers/cache_provider.ts":{"bytesInOutput":1658}},"bytes":2567},"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}}}
@@ -35,4 +35,8 @@ export default class CacheProvider {
35
35
  * Register bindings
36
36
  */
37
37
  register(): Promise<void>;
38
+ /**
39
+ * Gracefully shutdown connections when app goes down
40
+ */
41
+ shutdown(): Promise<void>;
38
42
  }
@@ -1,3 +1,5 @@
1
+ import "../chunk-EUXUH3YW.js";
2
+
1
3
  // src/bindings/repl.ts
2
4
  function setupReplState(repl, key, value) {
3
5
  repl.server.context[key] = value;
@@ -64,15 +66,25 @@ var CacheProvider = class {
64
66
  async #registerEdgeBindings() {
65
67
  if (!this.app.usingEdgeJS) return;
66
68
  const manager = await this.app.container.make("cache.manager");
67
- registerViewBindings(manager);
69
+ await registerViewBindings(manager);
68
70
  }
69
71
  /**
70
72
  * Register bindings
71
73
  */
72
74
  async register() {
73
- this.#registerCacheManager();
74
- this.#registerReplBindings();
75
- this.#registerEdgeBindings();
75
+ await this.#registerCacheManager();
76
+ await this.#registerReplBindings();
77
+ await this.#registerEdgeBindings();
78
+ }
79
+ /**
80
+ * Gracefully shutdown connections when app goes down
81
+ */
82
+ async shutdown() {
83
+ try {
84
+ const cache = await this.app.container.make("cache.manager");
85
+ await cache.disconnectAll();
86
+ } catch (_e) {
87
+ }
76
88
  }
77
89
  };
78
90
  export {
@@ -1 +1 @@
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 registerViewBindings(manager)\n }\n\n /**\n * Register bindings\n */\n async register() {\n this.#registerCacheManager()\n this.#registerReplBindings()\n this.#registerEdgeBindings()\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,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AAU,KAAK,eAAe;AAC7D,yBAAqB,OAAO;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,WAAW;AACf,SAAK,sBAAsB;AAC3B,SAAK,sBAAsB;AAC3B,SAAK,sBAAsB;AAAA,EAC7B;AACF;","names":[]}
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,8CAA8C;AAAA,EAC/D;AACF;;;ACzBA,SAAS,gBAAgB;AAEzB,IAAO,gBAAQ,SAAS,gBAAgB;;;ACCxC,eAAsB,qBAAqB,SAAuB;AAChE,QAAM,OAAO,MAAM,OAAO,SAAS;AACnC,gBAAM,8DAA8D;AAEpE,OAAK,QAAQ,OAAO,SAAS,OAAO;AACtC;;;AC4BA,IAAqB,gBAArB,MAAmC;AAAA,EACjC,YAAsB,KAAyB;AAAzB;AAAA,EAA0B;AAAA;AAAA;AAAA;AAAA,EAKhD,MAAM,wBAAwB;AAC5B,UAAM,cAAc,KAAK,IAAI,OAAO,IAAqC,OAAO;AAEhF,SAAK,IAAI,UAAU,UAAU,iBAAiB,YAAY;AACxD,YAAM,EAAE,WAAW,IAAI,MAAM,OAAO,YAAY;AAChD,YAAM,UAAU,MAAM,KAAK,IAAI,UAAU,KAAK,SAAS;AAKvD,YAAM,iBAAiB,OAAO,QAAQ,YAAY,MAAM,EAAE,IAAI,OAAO,CAAC,MAAM,KAAK,MAAM;AACrF,eAAO,CAAC,MAAM,MAAM,MAAM,MAAM,EAAE,SAAS,KAAK,GAAG,CAAC;AAAA,MACtD,CAAC;AAED,aAAO,IAAI,WAAW;AAAA,QACpB,GAAG;AAAA,QACH;AAAA,QACA,SAAS,YAAY;AAAA,QACrB,QAAQ,OAAO,YAAY,MAAM,QAAQ,IAAI,cAAc,CAAC;AAAA,MAC9D,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,wBAAwB;AAC5B,QAAI,KAAK,IAAI,eAAe,MAAM,QAAQ;AACxC;AAAA,IACF;AAEA,UAAM,OAAO,MAAM,KAAK,IAAI,UAAU,KAAK,MAAM;AACjD,uBAAmB,KAAK,KAAK,IAAI;AAAA,EACnC;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,wBAAwB;AAC5B,QAAI,CAAC,KAAK,IAAI,YAAa;AAE3B,UAAM,UAAU,MAAM,KAAK,IAAI,UAAU,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,3 +1,5 @@
1
+ import "../chunk-EUXUH3YW.js";
2
+
1
3
  // services/main.ts
2
4
  import app from "@adonisjs/core/services/app";
3
5
  var cache;
@@ -1 +1 @@
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
+ {"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":[]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@adonisjs/cache",
3
3
  "description": "Official caching module for AdonisJS framework",
4
- "version": "1.0.0-6",
4
+ "version": "1.0.1",
5
5
  "engines": {
6
6
  "node": ">=20.6.0"
7
7
  },
@@ -22,12 +22,12 @@
22
22
  },
23
23
  "scripts": {
24
24
  "clean": "del-cli build",
25
- "copy:templates": "copyfiles \"stubs/**/*.stub\" build",
25
+ "copy:templates": "copyfiles --up 1 \"stubs/**/*.stub\" build",
26
26
  "typecheck": "tsc --noEmit",
27
27
  "index:commands": "adonis-kit index build/commands",
28
28
  "lint": "eslint",
29
29
  "format": "prettier --write .",
30
- "quick:test": "node --import=ts-node-maintained/register/esm bin/test.ts",
30
+ "quick:test": "node --enable-source-maps --import=ts-node-maintained/register/esm 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",
@@ -39,38 +39,40 @@
39
39
  },
40
40
  "devDependencies": {
41
41
  "@adonisjs/assembler": "^7.8.2",
42
- "@adonisjs/core": "^6.17.0",
42
+ "@adonisjs/core": "^6.17.1",
43
43
  "@adonisjs/eslint-config": "^2.0.0-beta.7",
44
- "@adonisjs/lucid": "21.6.0",
44
+ "@adonisjs/lucid": "^21.6.0",
45
45
  "@adonisjs/prettier-config": "^1.4.0",
46
- "@adonisjs/redis": "9.1.0",
46
+ "@adonisjs/redis": "^9.1.1",
47
47
  "@adonisjs/tsconfig": "^1.4.0",
48
- "@japa/assert": "4.0.0",
49
- "@japa/expect-type": "^2.0.2",
50
- "@japa/file-system": "^2.3.1",
51
- "@japa/runner": "^3.1.4",
52
- "@japa/snapshot": "^2.0.7",
53
- "@release-it/conventional-changelog": "^9.0.4",
54
- "@swc/core": "^1.10.4",
55
- "@types/node": "^22.10.5",
56
- "better-sqlite3": "^11.7.2",
48
+ "@japa/assert": "^4.0.1",
49
+ "@japa/expect-type": "^2.0.3",
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.0",
54
+ "@swc/core": "^1.10.12",
55
+ "@types/node": "~20.17.16",
56
+ "better-sqlite3": "^11.8.1",
57
57
  "c8": "^10.1.3",
58
58
  "copyfiles": "^2.4.1",
59
59
  "del-cli": "^6.0.0",
60
- "edge.js": "^6.2.0",
61
- "eslint": "^9.17.0",
60
+ "edge.js": "^6.2.1",
61
+ "eslint": "^9.19.0",
62
62
  "ioredis": "^5.4.2",
63
63
  "knex": "^3.1.0",
64
64
  "luxon": "^3.5.0",
65
+ "mysql2": "^3.12.0",
65
66
  "p-event": "^6.0.1",
67
+ "pg": "^8.13.1",
66
68
  "prettier": "^3.4.2",
67
- "release-it": "^17.11.0",
68
- "ts-node-maintained": "^10.9.4",
69
- "tsup": "^8.3.5",
70
- "typescript": "~5.7.2"
69
+ "release-it": "^18.1.2",
70
+ "ts-node-maintained": "^10.9.5",
71
+ "tsup": "^8.3.6",
72
+ "typescript": "~5.7.3"
71
73
  },
72
74
  "dependencies": {
73
- "bentocache": "1.0.0-beta.11"
75
+ "bentocache": "^1.0.0"
74
76
  },
75
77
  "peerDependencies": {
76
78
  "@adonisjs/assembler": "^7.0.0",
@@ -86,7 +88,10 @@
86
88
  "optional": true
87
89
  }
88
90
  },
89
- "author": "adonisjs, Julien Ripouteau",
91
+ "author": "Julien Ripouteau <julien@ripouteau.com>",
92
+ "contributors": [
93
+ "Romain Lanz <romain.lanz@pm.me>"
94
+ ],
90
95
  "license": "MIT",
91
96
  "keywords": [
92
97
  "adonisjs",
@@ -94,6 +99,18 @@
94
99
  "caching",
95
100
  "bentocache"
96
101
  ],
102
+ "homepage": "https://github.com/adonisjs/cache#readme",
103
+ "repository": {
104
+ "type": "git",
105
+ "url": "git+https://github.com/adonisjs/cache.git"
106
+ },
107
+ "bugs": {
108
+ "url": "https://github.com/adonisjs/cache/issues"
109
+ },
110
+ "publishConfig": {
111
+ "provenance": true,
112
+ "access": "public"
113
+ },
97
114
  "prettier": "@adonisjs/prettier-config",
98
115
  "release-it": {
99
116
  "git": {
@@ -133,7 +150,8 @@
133
150
  "index.ts",
134
151
  "src/types.ts",
135
152
  "providers/cache_provider.ts",
136
- "services/main.ts"
153
+ "services/main.ts",
154
+ "commands/cache_clear.ts"
137
155
  ],
138
156
  "outDir": "./build",
139
157
  "clean": true,
@@ -141,6 +159,5 @@
141
159
  "dts": false,
142
160
  "sourcemap": true,
143
161
  "target": "esnext"
144
- },
145
- "packageManager": "pnpm@9.15.2"
162
+ }
146
163
  }
@@ -1,45 +0,0 @@
1
- {{{
2
- exports({ to: app.configPath('cache.ts') })
3
- }}}
4
- import env from '#start/env'
5
- {{#if driver === 'file'}}
6
- import app from '@adonisjs/core/services/app'
7
- {{/if}}
8
- import { defineConfig, store, drivers } from '@adonisjs/cache'
9
-
10
- const cacheConfig = defineConfig({
11
- default: '{{ driver }}',
12
- stores: {
13
- {{#if driver === 'database'}}
14
- database: store().useL2Layer(drivers.database({
15
- connectionName: 'primary',
16
- }))
17
- {{#elif driver === 'redis'}}
18
- redis: store().useL2Layer(drivers.redis({
19
- connectionName: 'main',
20
- }))
21
- {{#elif driver === 'memory'}}
22
- memory: store().useL1Layer(drivers.memory())
23
- {{#elif driver === 'file'}}
24
- file: store().useL2Layer(drivers.file({
25
- directory: app.tmpPath('cache')
26
- }))
27
- {{#elif driver === 'dynamodb'}}
28
- dynamodb: store().useL2Layer(drivers.dynamodb({
29
- table: { name: 'cache' },
30
- credentials: {
31
- accessKeyId: env.get('AWS_ACCESS_KEY_ID'),
32
- secretAccessKey: env.get('AWS_SECRET_ACCESS_KEY')
33
- },
34
- region: env.get('AWS_REGION'),
35
- endpoint: env.get('DYNAMODB_ENDPOINT')
36
- }))
37
- {{/if}}
38
- }
39
- })
40
-
41
- export default cacheConfig
42
-
43
- declare module '@adonisjs/cache/types' {
44
- interface CacheStores extends InferStores<typeof cacheConfig> {}
45
- }