BVB Source Codes

parse-server Show RedisCacheAdapter.spec.js Source code

Return Download parse-server: download RedisCacheAdapter.spec.js Source code - Download parse-server Source code - Type:.js
  1. var RedisCacheAdapter = require('../src/Adapters/Cache/RedisCacheAdapter').default;
  2. /*
  3. To run this test part of the complete suite
  4. set PARSE_SERVER_TEST_CACHE='redis'
  5. and make sure a redis server is available on the default port
  6.  */
  7. describe_only(() => {
  8.   return process.env.PARSE_SERVER_TEST_CACHE === 'redis';
  9. })('RedisCacheAdapter', function() {
  10.   var KEY = 'hello';
  11.   var VALUE = 'world';
  12.  
  13.   function wait(sleep) {
  14.     return new Promise(function(resolve) {
  15.       setTimeout(resolve, sleep);
  16.     })
  17.   }
  18.  
  19.   it('should get/set/clear', (done) => {
  20.     var cache = new RedisCacheAdapter({
  21.       ttl: NaN
  22.     });
  23.  
  24.     cache.put(KEY, VALUE)
  25.       .then(() => cache.get(KEY))
  26.       .then((value) => expect(value).toEqual(VALUE))
  27.       .then(() => cache.clear())
  28.       .then(() => cache.get(KEY))
  29.       .then((value) => expect(value).toEqual(null))
  30.       .then(done);
  31.   });
  32.  
  33.   it('should expire after ttl', (done) => {
  34.     var cache = new RedisCacheAdapter(null, 1);
  35.  
  36.     cache.put(KEY, VALUE)
  37.       .then(() => cache.get(KEY))
  38.       .then((value) => expect(value).toEqual(VALUE))
  39.       .then(wait.bind(null, 2))
  40.       .then(() => cache.get(KEY))
  41.       .then((value) => expect(value).toEqual(null))
  42.       .then(done);
  43.   });
  44.  
  45.   it('should find un-expired records', (done) => {
  46.     var cache = new RedisCacheAdapter(null, 5);
  47.  
  48.     cache.put(KEY, VALUE)
  49.       .then(() => cache.get(KEY))
  50.       .then((value) => expect(value).toEqual(VALUE))
  51.       .then(wait.bind(null, 1))
  52.       .then(() => cache.get(KEY))
  53.       .then((value) => expect(value).not.toEqual(null))
  54.       .then(done);
  55.   });
  56. });
  57.  
downloadRedisCacheAdapter.spec.js Source code - Download parse-server Source code
Related Source Codes/Software:
react-boilerplate - 2017-06-07
webtorrent - Streaming torrent client for the web ... 2017-06-06
machine-learning-for-software-engineers - A complete daily plan for studying to become a mac... 2017-06-06
upterm - A terminal emulator for the 21st century. 2017-06-06
lottie-android - Render After Effects animations natively on Androi... 2017-06-07
AsyncDisplayKit - Smooth asynchronous user interfaces for iOS apps. ... 2017-06-07
ionicons - The premium icon font for Ionic ... 2017-06-07
storybook - 2017-06-07
prettier - Prettier is an opinionated JavaScript formatter. ... 2017-06-08
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top