https://github.com/andstor/active-cache
:package::hourglass_flowing_sand: A simple caching object with TTL
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (11.9%) to scientific vocabulary
Keywords
Repository
:package::hourglass_flowing_sand: A simple caching object with TTL
Basic Info
Statistics
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
- Releases: 1
Topics
Metadata Files
README.md
ActiveCache 
A simple caching object with TTL
Table of Contents
Installation
html
<script src="/path/to/active-cache.js"></script>
Download the latest standalone JavaScript files (ES5)
Usage
Syntax
new ActiveCache(options?)
* options (optional)
* Type: Object
* The options for the caching. Check out the available options.
Example
```js const activeCache = new ActiveCache({prefix: 'c', stTTL: null}); activeCache.set("myKey", "A value", 60);
// After 40 minutes: activeCache.get("myKey") //=> {value: "myKey", ttl: 1575952773409}
// After 1 hour: activeCache.get("myKey") //=> null ```
Options
The ActiveCache class also support multiple optional configurations. These should be passed as an object to the ActiveCache class object. If no manual configurations are set, default options are used.
stTTL
- Type:
Boolean - Default:
null
Standard time to live. null = unlimited time.
prefix
- Type:
String - Default:
c
The prefix is used for all keys in the stored in SessionStorage, on the form prefix:key.
Methods
set(key, value, ttl?)
key:
- Type:
String - Key for storing the value.
- Type:
value:
- Type:
- Any value that can be converted to JSON.
- Type:
ttl:
- Type:
Numberornull - "Time to live", the time a cache object is valid.
null= unlimited time.
- Type:
(return value):
- Type:
Boolean - Returns true if the entry was successfully stored. False otherwise.
- Type:
Sets a key value pair.
get(key)
key:
- Type:
String - Key for storing the value.
- Type:
(return value):
- Type:
Object - Returns the item stored by the provided key.
- Type:
Gets an item on the form {value: "value", ttl: 1575952773409}, stored by a given key.
del(key)
key:
- Type:
String - Key for the entry to be deleted.
- Type:
(return value):
- Type:
Object - Returns the item stored by the provided key.
- Type:
Deletes an entry with the given key.
clear()
Deletes all entries stored by the ActiveCache with the currently used prefix.
Build instructions
Clone a copy of the main active-cache git repo by running:
bash
git clone git://github.com/andstor/active-cache.git
Enter the active-cache directory and run the build script:
bash
npm run build
Owner
- Name: André Storhaug
- Login: andstor
- Kind: user
- Location: Trondheim 🇳🇴
- Company: NTNU
- Website: https://andre.storhaug.no
- Repositories: 87
- Profile: https://github.com/andstor
🎓 CS PhD student @ Norwegian University of Science and Technology (NTNU)
GitHub Events
Total
Last Year
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 0
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 0
- Total pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- @babel/core ^7.5.5 development
- @babel/preset-env ^7.5.5 development
- babel-loader ^8.0.6 development
- webpack ^4.36.1 development
- webpack-cli ^3.3.6 development