javascript - Implenting local storage for each request in node.js -


i instrument node.js application, these need find out method belongs request, these have maintained unique id each request, should store id accessible methods , should separate each request. need thread-local concept of java in nodejs,

try node-cache

it's pretty easy use

var nodecache = require('nodecache'); var mycache = new nodecache(); var obj = {'some': 'object'}; mycache.set('key', obj); var cached = mycache.get('key'); 

it won't work if have node cluster believe. in case you'll have use external system redis.

of course, javascript objects can used associative arrays:

var associativearray = {}; associativearray.foo = 'bar'; associativearray['bar'] = associativearray['foo']; 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -