Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. 'use strict';
  2. const Cfapi = require('./cfapi');
  3. const NodeCache = require("node-cache");
  4. const co = require('co');
  5.  
  6. class Appcache {
  7. constructor() {
  8. this.cfapi = new Cfapi();
  9. this.myCache = new NodeCache();
  10. //this.interval = setInterval(populateCache(), 10000);
  11. this.counter = 0
  12. setInterval(function() {
  13. console.log('Bar', this.counter);
  14. this.counter++;
  15. // if (this.counter >= 3) {
  16. // clearInterval(interval);
  17. // }
  18. }, 1000);
  19. }
  20.  
  21. populateCache() {
  22. let cfToken = this.cfapi.getCFToken()
  23. //console.log(JSON.parse(cfToken).access_token);
  24. let bearerToken = this.cfapi.getBearerToken(cfToken)
  25. let allApps = this.cfapi.getAllApps(bearerToken)
  26. this.myCache.flushAll()
  27. for (app in JSON.parse(allApps).resources) {
  28. console.log(app)
  29. this.myCache.set(app.entity.name, app.entity.instances)
  30. }
  31. }
  32. }
  33.  
  34. module.exports = Appcache;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement