-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cache): support for in-memory cache
- Loading branch information
1 parent
f1bf6e0
commit 7e7b61b
Showing
7 changed files
with
145 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
'use strict' | ||
|
||
/* | ||
* edge | ||
* | ||
* (c) Harminder Virk <virk@adonisjs.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
class Cache { | ||
constructor () { | ||
this._items = {} | ||
} | ||
|
||
/** | ||
* Add key value pair to the memory cache | ||
* | ||
* @method add | ||
* | ||
* @param {String} location | ||
* @param {String} output | ||
* | ||
* @return {void} | ||
*/ | ||
add (location, output) { | ||
this._items[location] = output | ||
} | ||
|
||
/** | ||
* Get value back from the cache | ||
* | ||
* @method get | ||
* | ||
* @param {String} location | ||
* | ||
* @return {String} | ||
*/ | ||
get (location) { | ||
return this._items[location] | ||
} | ||
|
||
/** | ||
* Remove item from the cache | ||
* | ||
* @method remove | ||
* | ||
* @param {String} location | ||
* | ||
* @return {void} | ||
*/ | ||
remove (location) { | ||
delete this._items[location] | ||
} | ||
} | ||
|
||
module.exports = new Cache() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.