@adonisjs/cache 1.3.0 → 1.3.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.
@@ -1 +1 @@
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":2238,"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":5176,"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"},"commands/cache_delete.ts":{"bytes":2514,"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"},"commands/cache_prune.ts":{"bytes":2313,"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":15172},"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":1487},"src/define_config.ts":{"bytesInOutput":51},"src/drivers.ts":{"bytesInOutput":3424}},"bytes":6619},"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/commands/cache_delete.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":3932},"build/commands/cache_delete.js":{"imports":[{"path":"build/chunk-EUXUH3YW.js","kind":"import-statement"},{"path":"@adonisjs/core/ace","kind":"import-statement","external":true}],"exports":["default"],"entryPoint":"commands/cache_delete.ts","inputs":{"commands/cache_delete.ts":{"bytesInOutput":1914}},"bytes":2038},"build/commands/cache_prune.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":3481},"build/commands/cache_prune.js":{"imports":[{"path":"build/chunk-EUXUH3YW.js","kind":"import-statement"},{"path":"@adonisjs/core/ace","kind":"import-statement","external":true}],"exports":["default"],"entryPoint":"commands/cache_prune.ts","inputs":{"commands/cache_prune.ts":{"bytesInOutput":1727}},"bytes":1849},"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
+ {"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":2238,"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":5176,"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"},"commands/cache_delete.ts":{"bytes":2514,"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"},"commands/cache_prune.ts":{"bytes":2313,"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":479,"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":3119,"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":1041,"imports":[{"path":"bentocache/types","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"build/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":15172},"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":1487},"src/define_config.ts":{"bytesInOutput":51},"src/drivers.ts":{"bytesInOutput":3424}},"bytes":6619},"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/commands/cache_delete.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":3932},"build/commands/cache_delete.js":{"imports":[{"path":"build/chunk-EUXUH3YW.js","kind":"import-statement"},{"path":"@adonisjs/core/ace","kind":"import-statement","external":true}],"exports":["default"],"entryPoint":"commands/cache_delete.ts","inputs":{"commands/cache_delete.ts":{"bytesInOutput":1914}},"bytes":2038},"build/commands/cache_prune.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":3481},"build/commands/cache_prune.js":{"imports":[{"path":"build/chunk-EUXUH3YW.js","kind":"import-statement"},{"path":"@adonisjs/core/ace","kind":"import-statement","external":true}],"exports":["default"],"entryPoint":"commands/cache_prune.ts","inputs":{"commands/cache_prune.ts":{"bytesInOutput":1727}},"bytes":1849},"build/providers/cache_provider.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":6846},"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":1692}},"bytes":2596},"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":1207},"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}}}
@@ -34,7 +34,11 @@ export default class CacheProvider {
34
34
  /**
35
35
  * Register bindings
36
36
  */
37
- register(): Promise<void>;
37
+ register(): void;
38
+ /**
39
+ * Boot provider
40
+ */
41
+ boot(): Promise<void>;
38
42
  /**
39
43
  * Gracefully shutdown connections when app goes down
40
44
  */
@@ -34,7 +34,7 @@ var CacheProvider = class {
34
34
  /**
35
35
  * Register the cache manager to the container
36
36
  */
37
- async #registerCacheManager() {
37
+ #registerCacheManager() {
38
38
  const cacheConfig = this.app.config.get("cache");
39
39
  this.app.container.singleton("cache.manager", async () => {
40
40
  const { BentoCache } = await import("bentocache");
@@ -71,10 +71,15 @@ var CacheProvider = class {
71
71
  /**
72
72
  * Register bindings
73
73
  */
74
- async register() {
75
- await this.#registerCacheManager();
76
- await this.#registerReplBindings();
74
+ register() {
75
+ this.#registerCacheManager();
76
+ }
77
+ /**
78
+ * Boot provider
79
+ */
80
+ async boot() {
77
81
  await this.#registerEdgeBindings();
82
+ await this.#registerReplBindings();
78
83
  }
79
84
  /**
80
85
  * Gracefully shutdown connections when app goes down
@@ -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 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
+ {"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 { type 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 { type 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 #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 register() {\n this.#registerCacheManager()\n }\n\n /**\n * Boot provider\n */\n async boot() {\n await this.#registerEdgeBindings()\n await this.#registerReplBindings()\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,wBAAwB;AACtB,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,WAAW;AACT,SAAK,sBAAsB;AAAA,EAC7B;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,OAAO;AACX,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,2 +1,2 @@
1
- import { CacheService } from '../types.js';
1
+ import { type CacheService } from '../types.js';
2
2
  export declare function registerViewBindings(manager: CacheService): Promise<void>;
@@ -1 +1 @@
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":[]}
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 extends BentoCache<\n CacheStores extends Record<string, ReturnType<typeof bentostore>> ? CacheStores : never\n> {}\n"],"mappings":";AASA,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.3.0",
4
+ "version": "1.3.1",
5
5
  "engines": {
6
6
  "node": ">=20.6.0"
7
7
  },