Methods
about(detailedopt) → {console.log}
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
detailed |
string | boolean | number |
<optional> |
"" | To get full details or not. >1 | 0, true | false, "yes" | "", "yes" | "no". Not case sensitive. |
Returns:
Logs the details into the console, so it doesn't return anything.
- Type
- console.log
Examples
Example 1
const {about} = require('arch881010-cache');
about(false); // OR about(true);
Example 2
const cache = require('arch881010-cache');
cache.about(false); // OR about(true);
add(key, value)
This module requires node:fs.
Parameters:
Name | Type | Description |
---|---|---|
key |
string | The cache key you want to save it as. |
value |
string | The value for the cache key you saved it as (key). |
Returns:
If its successful, it doesn't return anything. Otherwise, it returns a reference error.
Examples
Example 1
const {add} = require('arch881010-cache');
add("name","value");
Example 2
const cache = require('arch881010-cache');
cache.add("key","value");
addCache(key, value)
This module requires node:fs.
Parameters:
Name | Type | Description |
---|---|---|
key |
string | The cache key you want to save it as. |
value |
string | The value for the cache key you saved it as (key). |
Returns:
If its successful, it doesn't return anything. Otherwise, it returns a reference error.
Examples
Example 1
const {addCache} = require('arch881010-cache');
addCache("name","value");
Example 2
const cache = require('arch881010-cache');
cache.addCache("key","value");
clear(passwordopt)
This module requires node:fs.
Allows the user to easily clear the cache. (Instead of navigating to "./node_modules/arch881010-files/cache.json")
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
password |
string |
<optional> |
"" | Your password to clear the cache. |
Returns:
If its successful, it doesn't return anything. Otherwise, it logs an error for being the wrong password.
Examples
Example 1
const {clear} = require('arch881010-cache');
clear(password);
Example 2
const cache = require('arch881010-cache');
cache.clear(password);
clearCache(passwordopt)
Use cache.clear() instead.
This module requires node:fs.
Allows the user to easily clear the cache. (Instead of navigating to "./node_modules/arch881010-files/cache.json")
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
password |
string |
<optional> |
"" | Your password to clear the cache. |
Returns:
If its successful, it doesn't return anything. Otherwise, it logs an error for being the wrong password.
Examples
Example 1
const {clearCache} = require('arch881010-cache');
clearCache(password);
Example 2
const cache = require('arch881010-cache');
cache.clearCache(password);
content(howopt) → {string|object}
Allows a way to easily export cache. Defaults to string. Derived from "getFullCacheContent()"
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
how |
string |
<optional> |
"Str" | "Obj"/"Str" (Not case sensitive) |
Returns:
Returns the cache content as an string or object.
- Type
- string | object
Example
Example
const cache = require('arch881010-cache');
var data = cache.content("Str"); // or "Obj" (Not case sensitive)
delete(key)
This module requires node:fs.
This does not require the password.
Parameters:
Name | Type | Description |
---|---|---|
key |
string | They key your deleting. |
Returns:
If its successful, it doesn't return anything. Otherwise, it returns a reference error.
Example
Example
const cache = require('arch881010-cache');
cache.delete("key");
deleteFromCache(key)
Parameters:
Name | Type | Description |
---|---|---|
key |
string | They key your deleting. |
- Since:
- 1.0.0
- Deprecated:
- 1.0.5 Use cache.delete() instead. This module requires node:fs. This does not require the password.
- Source:
Returns:
If its successful, it doesn't return anything. Otherwise, it returns a reference error.
Examples
Example 1
const {deleteFromCache} = require('arch881010-cache');
deleteFromCache("name");
Example 2
const cache = require('arch881010-cache');
cache.deleteFromCache("key");
deleteMatching(match)
Parameters:
Name | Type | Description |
---|---|---|
match |
string | A string to match to delete all keys with that name. |
Returns:
Nothing, cache is updated.
get(key) → {string}
This module requires node:fs.
This does not require the password.
Parameters:
Name | Type | Description |
---|---|---|
key |
string | They key your retrieving from the cache. |
Returns:
If its successful, it returns the value. Otherwise, it returns a reference error.
- Type
- string
Examples
Example 1
const {get} = require('arch881010-cache');
var result = get("name","value");
Example 2
const cache = require('arch881010-cache');
var result = cache.get("key","value");
getFromCache(key) → {string}
Use cache.get() instead.
This module requires node:fs.
This does not require the password.
Parameters:
Name | Type | Description |
---|---|---|
key |
string | They key your retrieving from the cache. |
Returns:
If its successful, it will return your requested value. Otherwise, it will return an empty string and logs a notice.
- Type
- string
Examples
Example 1
const {getFromCache} = require('arch881010-cache');
var result = getFromCache("name","value");
Example 2
const cache = require('arch881010-cache');
var result = cache.getFromCache("key","value");
getFullCacheContent(howopt) → {string|object}
This module requires node:fs.
Allows a way to easily export cache. Defaults to string.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
how |
string |
<optional> |
"Str" | "Obj"/"Str" (Not case sensitive) |
Returns:
Returns the cache content as an string or object.
- Type
- string | object
Examples
Example 1
const {getFullCacheContent} = require('arch881010-cache');
var data = getFullCacheContent("Str"); // or "Obj" (Not case sensitive)
Example 2
const cache = require('arch881010-cache');
var data = cache.getFullCacheContent("Str") // or "Obj" (Not case sensitive)
new(passwordopt)
This module requires node:fs.
Password is allowed to prevent destructive clear() by external eval().
You cannot use const {new} = require('arch881010-cache') as new is a saved word.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
password |
string |
<optional> |
"" | Your password to "lock" (optional) |
Returns:
It is always successful, thus, it returns nothing.
Example
Example
const cache = require('arch881010-cache');
cache.new(password)
newCache(passwordopt)
This module requires node:fs.
Password is allowed to prevent destructive clear() by external eval().
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
password |
string |
<optional> |
"" | Your password to "lock" clearing cache (optional) |
Returns:
Always successful (if installed correctly), which results in nothing.
Examples
Example 1
const {newCache} = require('arch881010-cache');
newCache(password);
Example 2
const cache = require('arch881010-cache');
cache.newCache(password);
remove(key)
This module requires node:fs.
This does not require the password.
Parameters:
Name | Type | Description |
---|---|---|
key |
string | They key your deleting. |
Returns:
If its successful, it doesn't return anything. Otherwise, it returns a reference error.
Example
Example
const cache = require('arch881010-cache');
cache.remove("key");
size() → {string}
Returns:
The cache size in bytes.
- Type
- string
Examples
const {size} = require('arch881010-cache');
console.log(size());
const cache = require('arch881010-cache');
console.log(cache.size());
update(key, value)
This module requires node:fs.
Parameters:
Name | Type | Description |
---|---|---|
key |
string | They key's name your changing. |
value |
string | The value for the cache key you saved it as (key). |
Returns:
If its successful, it doesn't return anything. Otherwise, it creates a new key and saves it as that value.
Examples
Example 1
const {update} = require('arch881010-cache');
update("name","value");
Example 2
const cache = require('arch881010-cache');
cache.update("key","value");
updateCache(key, value)
This module requires node:fs.
Parameters:
Name | Type | Description |
---|---|---|
key |
string | They key's name your changing. |
value |
string | The value for the cache key you saved it as (key). |
Returns:
If its successful, it doesn't return anything. Otherwise, it sets a new key as that value.
Examples
Example 1
const {updateCache} = require('arch881010-cache');
updateCache("name","value");
Example 2
const cache = require('arch881010-cache');
cache.updateCache("key","value");