@adonisjs/cache 1.0.2 → 1.1.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.
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "../chunk-EUXUH3YW.js";
|
|
4
4
|
|
|
5
5
|
// commands/cache_clear.ts
|
|
6
|
-
import { args, BaseCommand } from "@adonisjs/core/ace";
|
|
6
|
+
import { args, BaseCommand, flags } from "@adonisjs/core/ace";
|
|
7
7
|
var CacheClear = class extends BaseCommand {
|
|
8
8
|
static commandName = "cache:clear";
|
|
9
9
|
static description = "Clear the application cache";
|
|
@@ -49,13 +49,24 @@ var CacheClear = class extends BaseCommand {
|
|
|
49
49
|
const shouldClear = await this.#takeProductionConsent();
|
|
50
50
|
if (!shouldClear) return;
|
|
51
51
|
}
|
|
52
|
-
|
|
53
|
-
this.
|
|
52
|
+
const cacheHandler = cache.use(this.store);
|
|
53
|
+
if (this.namespace) {
|
|
54
|
+
await cacheHandler.namespace(this.namespace).clear();
|
|
55
|
+
this.logger.success(
|
|
56
|
+
`Cleared namespace "${this.namespace}" for "${this.store}" cache successfully`
|
|
57
|
+
);
|
|
58
|
+
} else {
|
|
59
|
+
await cacheHandler.clear();
|
|
60
|
+
this.logger.success(`Cleared "${this.store}" cache successfully`);
|
|
61
|
+
}
|
|
54
62
|
}
|
|
55
63
|
};
|
|
56
64
|
__decorateClass([
|
|
57
65
|
args.string({ description: "Define a custom cache store to clear", required: false })
|
|
58
66
|
], CacheClear.prototype, "store", 2);
|
|
67
|
+
__decorateClass([
|
|
68
|
+
flags.string({ description: "Select a cache namespace to clear", alias: "n" })
|
|
69
|
+
], CacheClear.prototype, "namespace", 2);
|
|
59
70
|
export {
|
|
60
71
|
CacheClear as default
|
|
61
72
|
};
|
|
@@ -1 +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 { args, BaseCommand } from '@adonisjs/core/ace'\n\nimport { CacheService } from '../src/types.js'\nimport { CommandOptions } from '@adonisjs/core/types/ace'\n\nexport default class CacheClear extends BaseCommand {\n static commandName = 'cache:clear'\n static description = 'Clear the application cache'\n static options: CommandOptions = {\n startApp: true,\n }\n\n /**\n * Choose a custom cache store to clear. Otherwise, we use the\n * default one\n */\n @args.string({ description: 'Define a custom cache store to clear', required: false })\n declare store: string\n\n /**\n * Prompts to take consent when clearing the cache in production\n */\n async #takeProductionConsent(): Promise<boolean> {\n const question = 'You are in production environment. Want to continue clearing the cache?'\n try {\n return await this.prompt.confirm(question)\n } catch (error) {\n return false\n }\n }\n\n /**\n * Check if the given cache exist\n */\n #cacheExists(cache: CacheService, cacheName: string) {\n try {\n cache.use(cacheName)\n return true\n } catch (error) {\n return false\n }\n }\n\n /**\n * Handle command\n */\n async run() {\n const cache = await this.app.container.make('cache.manager')\n this.store = this.store || cache.defaultStoreName\n\n /**\n * Exit if cache store doesn't exist\n */\n if (!this.#cacheExists(cache, this.store)) {\n this.logger.error(\n `\"${this.store}\" is not a valid cache store. Double check config/cache.ts file`\n )\n this.exitCode = 1\n return\n }\n\n /**\n * 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
|
|
1
|
+
{"version":3,"sources":["../../commands/cache_clear.ts"],"sourcesContent":["/*\n * @adonisjs/cache\n *\n * (c) AdonisJS\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { args, BaseCommand, flags } from '@adonisjs/core/ace'\n\nimport { CacheService } from '../src/types.js'\nimport { CommandOptions } from '@adonisjs/core/types/ace'\n\nexport default class CacheClear extends BaseCommand {\n static commandName = 'cache:clear'\n static description = 'Clear the application cache'\n static options: CommandOptions = {\n startApp: true,\n }\n\n /**\n * Choose a custom cache store to clear. Otherwise, we use the\n * default one\n */\n @args.string({ description: 'Define a custom cache store to clear', required: false })\n declare store: string\n\n /**\n * Optionally select a namespace to clear. Defaults to the whole cache.\n */\n @flags.string({ description: 'Select a cache namespace to clear', alias: 'n' })\n declare namespace: string\n\n /**\n * Prompts to take consent when clearing the cache in production\n */\n async #takeProductionConsent(): Promise<boolean> {\n const question = 'You are in production environment. Want to continue clearing the cache?'\n try {\n return await this.prompt.confirm(question)\n } catch (error) {\n return false\n }\n }\n\n /**\n * Check if the given cache exist\n */\n #cacheExists(cache: CacheService, cacheName: string) {\n try {\n cache.use(cacheName)\n return true\n } catch (error) {\n return false\n }\n }\n\n /**\n * Handle command\n */\n async run() {\n const cache = await this.app.container.make('cache.manager')\n this.store = this.store || cache.defaultStoreName\n\n /**\n * Exit if cache store doesn't exist\n */\n if (!this.#cacheExists(cache, this.store)) {\n this.logger.error(\n `\"${this.store}\" is not a valid cache store. Double check config/cache.ts file`\n )\n this.exitCode = 1\n return\n }\n\n /**\n * Take consent when clearing the cache in production\n */\n if (this.app.inProduction) {\n const shouldClear = await this.#takeProductionConsent()\n if (!shouldClear) return\n }\n\n /**\n * Finally clear the cache\n */\n const cacheHandler = cache.use(this.store)\n if (this.namespace) {\n await cacheHandler.namespace(this.namespace).clear()\n this.logger.success(\n `Cleared namespace \"${this.namespace}\" for \"${this.store}\" cache successfully`\n )\n } else {\n await cacheHandler.clear()\n this.logger.success(`Cleared \"${this.store}\" cache successfully`)\n }\n }\n}\n"],"mappings":";;;;;AASA,SAAS,MAAM,aAAa,aAAa;AAKzC,IAAqB,aAArB,cAAwC,YAAY;AAAA,EAClD,OAAO,cAAc;AAAA,EACrB,OAAO,cAAc;AAAA,EACrB,OAAO,UAA0B;AAAA,IAC/B,UAAU;AAAA,EACZ;AAAA;AAAA;AAAA;AAAA,EAkBA,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,eAAe,MAAM,IAAI,KAAK,KAAK;AACzC,QAAI,KAAK,WAAW;AAClB,YAAM,aAAa,UAAU,KAAK,SAAS,EAAE,MAAM;AACnD,WAAK,OAAO;AAAA,QACV,sBAAsB,KAAK,SAAS,UAAU,KAAK,KAAK;AAAA,MAC1D;AAAA,IACF,OAAO;AACL,YAAM,aAAa,MAAM;AACzB,WAAK,OAAO,QAAQ,YAAY,KAAK,KAAK,sBAAsB;AAAA,IAClE;AAAA,EACF;AACF;AAxEU;AAAA,EADP,KAAK,OAAO,EAAE,aAAa,wCAAwC,UAAU,MAAM,CAAC;AAAA,GAXlE,WAYX;AAMA;AAAA,EADP,MAAM,OAAO,EAAE,aAAa,qCAAqC,OAAO,IAAI,CAAC;AAAA,GAjB3D,WAkBX;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"commands":[{"commandName":"cache:clear","description":"Clear the application cache","help":"","namespace":"cache","aliases":[],"flags":[],"args":[{"name":"store","argumentName":"store","required":false,"description":"Define a custom cache store to clear","type":"string"}],"options":{"startApp":true},"filePath":"cache_clear.js"}],"version":1}
|
|
1
|
+
{"commands":[{"commandName":"cache:clear","description":"Clear the application cache","help":"","namespace":"cache","aliases":[],"flags":[{"name":"namespace","flagName":"namespace","required":false,"type":"string","description":"Select a cache namespace to clear","alias":"n"}],"args":[{"name":"store","argumentName":"store","required":false,"description":"Define a custom cache store to clear","type":"string"}],"options":{"startApp":true},"filePath":"cache_clear.js"}],"version":1}
|
package/build/metafile-esm.json
CHANGED
|
@@ -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":"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":
|
|
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":2583,"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":3999},"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":1953}},"bytes":2075},"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}}}
|
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.
|
|
4
|
+
"version": "1.1.1",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=20.6.0"
|
|
7
7
|
},
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@adonisjs/eslint-config": "^2.0.0-beta.7",
|
|
44
44
|
"@adonisjs/lucid": "^21.6.0",
|
|
45
45
|
"@adonisjs/prettier-config": "^1.4.0",
|
|
46
|
-
"@adonisjs/redis": "^9.
|
|
46
|
+
"@adonisjs/redis": "^9.2.0",
|
|
47
47
|
"@adonisjs/tsconfig": "^1.4.0",
|
|
48
48
|
"@japa/assert": "^4.0.1",
|
|
49
49
|
"@japa/expect-type": "^2.0.3",
|
|
@@ -51,15 +51,15 @@
|
|
|
51
51
|
"@japa/runner": "^4.2.0",
|
|
52
52
|
"@japa/snapshot": "^2.0.8",
|
|
53
53
|
"@release-it/conventional-changelog": "^10.0.0",
|
|
54
|
-
"@swc/core": "^1.10.
|
|
55
|
-
"@types/node": "~20.17.
|
|
54
|
+
"@swc/core": "^1.10.15",
|
|
55
|
+
"@types/node": "~20.17.17",
|
|
56
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
60
|
"edge.js": "^6.2.1",
|
|
61
|
-
"eslint": "^9.
|
|
62
|
-
"ioredis": "^5.
|
|
61
|
+
"eslint": "^9.20.0",
|
|
62
|
+
"ioredis": "^5.5.0",
|
|
63
63
|
"knex": "^3.1.0",
|
|
64
64
|
"luxon": "^3.5.0",
|
|
65
65
|
"mysql2": "^3.12.0",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"typescript": "~5.7.3"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"bentocache": "^1.
|
|
75
|
+
"bentocache": "^1.1.0"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
78
|
"@adonisjs/assembler": "^7.0.0",
|