I am building a node.js application and have a set of attributes that I need to look up on every action (they are associated with permissions). I am using a mysql database as my persistant storage. I was initially going to use redis to store these attributes as they don't change that much and so can be loaded from the mysql database when the application is started and refreshed if they ever change. The point being that I need the lookup to be quick as it happens often, but the data doesn't need to persist.
As I was thinking about this today, it occurred to me that I could maybe use a global associative array to store this data. I am always going to be looking things up by the same key and always getting the full list of attributes. I figure that when I start the application on the server, it can just load the data into an array attached to the "global" object in node rather than sticking it into redis so I can reduce the complexity of the app stack. Plus I'm assuming that the javascript array would be a faster lookup as well since it's less overhead.
Am I missing something? Is there something about the way either redis or the global object in node works that would make the former faster? I anticipate the most likely situation would be 100's of keys but there could be situations where I could have 10000's. That still doesn't seem too big in the grand scheme of things though.
Aucun commentaire:
Enregistrer un commentaire