quickset
v1.0.0
Published
quickset is a module that allows you to easily share variables with other modules
Downloads
6
Readme
quickset
quickset is a module that allows you to easily share variables with other modules.
Installation
npm i quickset --save
Keep in mind, it's stored in RAM, if you put a massive ass data set in ram your computer will hate you :) This also means that once the process stops ALL DATA is lost.
If you have enough ram, you can store a pretty big dataset, the speed in which it grabs the values is virtually instant. This is like a virtual database but much much faster, don't forget once the process closes all data is lost.
Example
test.js
const { set } = require('quickset');
setInterval(() => {
set('pewpy_pants', 'I just pewped my pants ' + Math.random() + ' times');
}, 2000);
testTwo.js
const { get, set, destroy, returnKeysThatMatchString } = require('quickset');
...
server.get('/get', (req, res) => {
// returns null if property does not exist
res.send(get('pewpy_pants'));
});
server.get('/getkeys', (req, res) => {
// once you have the key names that contain that string
// you can loop to grab each value using get()
res.send(returnKeysThatMatchString('pewpy'));
});
server.get('/set', (req, res) => {
set('pewpy_pants', 'I pewped my pants');
res.send('set pewpy_pants');
});
server.get('/remove', (req, res) => {
destroy('pewpy_pants');
res.send(get('pewpy_pants'));
});
...
Methods
get ( 'property_name' )
const { get } = require('quickset');
console.log(get('pewpy_pants'));
- get() will return null if property does not exist
set ( 'property_name' , property_value )
const { set } = require('quickset');
set('pewpy_pants', 'I pooped my pants');
- set() will create property if property does not exist
destroy ( 'property_name' )
const { destroy } = require('quickset');
destroy('pewpy_pants');
returnKeysThatMatchString ( 'searchString' )
const { returnKeysThatMatchString } = require('quickset');
console.log(returnKeysThatMatchString('pewpy'));