PHP Classes

File: test/test.js

Recommend this page to a friend!
  Classes of Nikos M.   Unicache   test/test.js   Download  
File: test/test.js
Role: Auxiliary data
Content typex: text/plain
Description: Auxiliary data
Class: Unicache
Store cached data in different storage types
Author: By
Last change:
Date: 2 months ago
Size: 921 bytes
 

Contents

Class file image Download
"use strict"; const UNICACHE = require(__dirname + '/../src/js/node/Unicache.js'); console.log('UNICACHE.VERSION = ' + UNICACHE.Factory.VERSION); const config = { 'cacheType' : 'FILE', 'prefix' : 'foo_', 'FILE' : { 'cacheDir' : __dirname + '/cache2' // will be created if it does not exist } }; const cache = UNICACHE.Factory.getCache(config); cache.putPromise('key', 'val', 10) .then(function(result) { setTimeout(function() { cache.getPromise('key') .then(function(val) { console.log(['val', val]); }) .catch(function(err) { throw err; }); }, 2000); setTimeout(function() { cache.getPromise('key') .then(function(val) { console.log(['val', val]); }) .catch(function(err) { throw err; }); }, 12000); }) .catch(function(err) { throw err; });