cacheUtil.js 581 B

12345678910111213141516171819202122232425
  1. /**
  2. * Created by Tony on 2016/12/28.
  3. */
  4. var cache = {};
  5. module.exports = {
  6. setCache: function(groupKey, cacheKey, cacheValue) {
  7. if (groupKey && cacheKey) {
  8. if (!(cache[groupKey])) {
  9. cache[groupKey] = {};
  10. }
  11. cache[groupKey][cacheKey] = cacheValue;
  12. return true;
  13. } else {
  14. return false;
  15. }
  16. },
  17. getCache: function(groupKey, cacheKey) {
  18. var rst = null;
  19. if (cache[groupKey]) {
  20. rst = cache[groupKey][cacheKey];
  21. }
  22. return rst;
  23. }
  24. }