Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict';
- const Cfapi = require('./cfapi');
- const NodeCache = require("node-cache");
- const co = require('co');
- class Appcache {
- constructor() {
- this.cfapi = new Cfapi();
- this.myCache = new NodeCache();
- //this.interval = setInterval(populateCache(), 10000);
- this.counter = 0
- setInterval(function() {
- console.log('Bar', this.counter);
- this.counter++;
- // if (this.counter >= 3) {
- // clearInterval(interval);
- // }
- }, 1000);
- }
- populateCache() {
- let cfToken = this.cfapi.getCFToken()
- //console.log(JSON.parse(cfToken).access_token);
- let bearerToken = this.cfapi.getBearerToken(cfToken)
- let allApps = this.cfapi.getAllApps(bearerToken)
- this.myCache.flushAll()
- for (app in JSON.parse(allApps).resources) {
- console.log(app)
- this.myCache.set(app.entity.name, app.entity.instances)
- }
- }
- }
- module.exports = Appcache;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement