adonis-cache
Advanced tools
| 'use strict' | ||
| /** | ||
| * adonis-cache | ||
| * | ||
| * (c) Hany El Nokaly <hany.elnokaly@gmail.com> | ||
| * | ||
| * For the full copyright and license information, please view the LICENSE | ||
| * file that was distributed with this source code. | ||
| */ | ||
| const TaggableStore = require('./TaggableStore') | ||
| class NullStore extends TaggableStore { | ||
| /** | ||
| * Retrieve an item from the cache by key. | ||
| * | ||
| * @param {string} key | ||
| * @return {Promise<mixed>} | ||
| */ | ||
| get (key) { | ||
| return Promise.resolve(null) | ||
| } | ||
| /** | ||
| * Retrieve multiple items from the cache by key. | ||
| * | ||
| * Items not found in the cache will have a null value. | ||
| * | ||
| * @param {Array<string>} keys | ||
| * @return {Promise<object>} | ||
| */ | ||
| many (keys) { | ||
| let mappedValues = {} | ||
| for (let key of keys) { | ||
| mappedValues[key] = null | ||
| } | ||
| return Promise.resolve(mappedValues) | ||
| } | ||
| /** | ||
| * Store an item in the cache for a given number of minutes. | ||
| * | ||
| * @param {string} key | ||
| * @param {mixed} value | ||
| * @param {float|int} minutes | ||
| * @return {Promise<void>} | ||
| */ | ||
| put (key, value, minutes) { | ||
| return Promise.resolve(undefined) | ||
| } | ||
| /** | ||
| * Store multiple items in the cache for a given number of minutes. | ||
| * | ||
| * @param {object} object | ||
| * @param {int} minutes | ||
| * @return {Promise<void>} | ||
| */ | ||
| putMany (object, minutes) { | ||
| return Promise.resolve(undefined) | ||
| } | ||
| /** | ||
| * Increment the value of an item in the cache. | ||
| * | ||
| * @param {string} key | ||
| * @param {mixed} value | ||
| * @return {Promise<int|boolean>} | ||
| */ | ||
| increment (key, value = 1) { | ||
| return Promise.resolve(false) | ||
| } | ||
| /** | ||
| * Decrement the value of an item in the cache. | ||
| * | ||
| * @param {string} key | ||
| * @param {mixed} value | ||
| * @return {Promise<int|boolean>} | ||
| */ | ||
| decrement (key, value = 1) { | ||
| return Promise.resolve(false) | ||
| } | ||
| /** | ||
| * Store an item in the cache indefinitely. | ||
| * | ||
| * @param {string} key | ||
| * @param {mixed} value | ||
| * @return {Promise<void>} | ||
| */ | ||
| forever (key, value) { | ||
| return Promise.resolve(undefined) | ||
| } | ||
| /** | ||
| * Remove an item from the cache. | ||
| * | ||
| * @param {string} key | ||
| * @return {Promise<boolean>} | ||
| */ | ||
| forget (key) { | ||
| return Promise.resolve(true) | ||
| } | ||
| /** | ||
| * Remove all items from the cache. | ||
| * | ||
| * @return {Promise<void>} | ||
| */ | ||
| flush () { | ||
| return Promise.resolve(undefined) | ||
| } | ||
| /** | ||
| * Get the cache key prefix. | ||
| * | ||
| * @return {string} | ||
| */ | ||
| getPrefix () { | ||
| return '' | ||
| } | ||
| } | ||
| module.exports = NullStore |
+1
-1
| { | ||
| "name": "adonis-cache", | ||
| "version": "0.2.0", | ||
| "version": "0.2.1", | ||
| "description": "Cache provider for AdonisJs framework", | ||
@@ -5,0 +5,0 @@ "scripts": { |
+1
-1
@@ -247,3 +247,3 @@ # AdonisCache | ||
| ```javasript | ||
| ```javascript | ||
| yield Cache.forget('key') | ||
@@ -250,0 +250,0 @@ ``` |
@@ -14,2 +14,3 @@ 'use strict' | ||
| const RedisStore = require('./RedisStore') | ||
| const NullStore = require('./NullStore') | ||
| const DatabaseStore = require('./DatabaseStore') | ||
@@ -113,5 +114,15 @@ const Repository = require('./Repository') | ||
| /** | ||
| * Create an instance of the Null cache driver. | ||
| * | ||
| * @return {Repository} | ||
| * @private | ||
| */ | ||
| _createNullDriver () { | ||
| return this.repository(new NullStore()) | ||
| } | ||
| /** | ||
| * Create an instance of the object cache driver. | ||
| * | ||
| * @return {ObjectStore} | ||
| * @return {Repository} | ||
| * @private | ||
@@ -127,3 +138,3 @@ */ | ||
| * @param {object} config | ||
| * @return {RedisStore} | ||
| * @return {Repository} | ||
| * @private | ||
@@ -141,3 +152,3 @@ */ | ||
| * @param {object} config | ||
| * @return {DatabaseStore} | ||
| * @return {Repository} | ||
| * @private | ||
@@ -144,0 +155,0 @@ */ |
@@ -13,8 +13,6 @@ 'use strict' | ||
| | | ||
| | This option controls the default cache connection that gets used while | ||
| | using this caching library. This connection is used when another is | ||
| | This option controls the default cache store that gets used while | ||
| | using this caching library. This store is used when another is | ||
| | not explicitly specified when executing a given caching function. | ||
| | | ||
| | Supported: "object", "database", "redis" | ||
| | | ||
| */ | ||
@@ -33,2 +31,5 @@ | ||
| | | ||
| | Supported drivers: "object", "database", "redis" | ||
| | Hint: Use "null" driver for disabling caching | ||
| | | ||
| */ | ||
@@ -53,2 +54,6 @@ | ||
| null: { | ||
| driver: 'null' | ||
| } | ||
| }, | ||
@@ -55,0 +60,0 @@ |
65291
4.44%26
4%1964
6.68%