cache.js 563 B

12345678910111213141516171819202122232425
  1. // A cache to keep track of html5player tokens, so that we don't request
  2. // these static files from Youtube and parse them every time a video
  3. // needs the same one.
  4. //
  5. // The cache is very simplistic, shared, and it only needs get and set.
  6. // No need for fancy stuff like cache.del() or cache.has().
  7. exports.store = {};
  8. /**
  9. * @param {String} key
  10. * @param {Object} value
  11. */
  12. exports.set = function(key, value) {
  13. exports.store[key] = value;
  14. };
  15. /**
  16. * @param {String} key
  17. * @return {Object}
  18. */
  19. exports.get = function(key) {
  20. return exports.store[key];
  21. };