spec.plugins.cache.js
This file
Path
spec/spec.plugins.cache.js
156 lines · 4.0 KiB · JavaScript
Last changed by
Merge branch 'async-cache'visionmediabefore adoption7606f1b
History of this fileTake it
The walk stopped after 200 commits: lines older than fa37e5a point at it.
Added "session reap threshold" settingvisionmediabefore adoptionfa37e5a
lines 1–21why, one step back12describe 'Express'3 before_each4 reset()5 use(require('express/plugins/cache').Cache)6 cache = require('express/plugins/cache')7 end8 9 describe 'Cache'10 describe 'Request'11 describe '#cache'12 it 'should use memory store by default'13 get('/item', function(){14 return this.cache.toString()15 })16 get('/item').body.should.eql '[Memory Store]'17 end18 end19 end20 end21 Merge branch 'cache-lifetime'visionmediabefore adoption5ce1306
lines 22–29why, one step back22 describe 'cache Store.Memory'23 before_each24 store = new cache.Store.Memory25 end26 27 describe '#toString()'28 it 'should return [Memory Store]'29 store.toString().should.eql '[Memory Store]'Added "session reap threshold" settingvisionmediabefore adoptionfa37e5a
line 30why, one step back30 endMerge branch 'cache-lifetime'visionmediabefore adoption5ce1306
lines 31–35why, one step back31 end32 33 describe '#set()'34 describe 'given a key and value'35 it 'should set the cache data'Merge branch 'async-cache'visionmediabefore adoption7606f1b
lines 36–42why, one step back36 var result37 store.set('foo', 'bar', function(){38 store.get('foo', function(val){39 result = val40 })41 })42 result.should.eql 'bar'Added "session reap threshold" settingvisionmediabefore adoptionfa37e5a
lines 43–44why, one step back43 end44 Merge branch 'cache-lifetime'visionmediabefore adoption5ce1306
line 45why, one step back45 it 'should override existing data'Merge branch 'async-cache'visionmediabefore adoption7606f1b
lines 46–54why, one step back46 var result47 store.set('foo', 'bar', function(){48 store.set('foo', 'baz', function(){49 store.get('foo', function(val){50 result = val51 })52 })53 })54 result.should.eql 'baz'Added "session reap threshold" settingvisionmediabefore adoptionfa37e5a
lines 55–57why, one step back55 end56 end57 Merge branch 'cache-lifetime'visionmediabefore adoption5ce1306
lines 58–60why, one step back58 describe 'given an abitrary key'59 it 'should throw an error'60 -{ store.set({}, 'foo') }.should.throw_errorAdded "session reap threshold" settingvisionmediabefore adoptionfa37e5a
line 61why, one step back61 endMerge branch 'cache-lifetime'visionmediabefore adoption5ce1306
lines 62–65why, one step back62 end63 64 describe 'given an abitrary value'65 it 'should serialize as JSON'Merge branch 'async-cache'visionmediabefore adoption7606f1b
lines 66–70why, one step back66 var result67 store.set('user', { name: 'tj' }, function(val){68 result = val69 })70 result.should.eql { name: 'tj' }Merge branch 'cache-lifetime'visionmediabefore adoption5ce1306
lines 71–77why, one step back71 end72 end73 end74 75 describe '#get()'76 describe 'given a key'77 it 'should unserialize JSON data'Merge branch 'async-cache'visionmediabefore adoption7606f1b
lines 78–84why, one step back78 var result79 store.set('user', { name: 'tj' }, function(){80 store.get('user', function(val){81 result = val82 })83 })84 result.should.eql { name: 'tj' }Added "session reap threshold" settingvisionmediabefore adoptionfa37e5a
lines 85–87why, one step back85 end86 end87 Merge branch 'cache-lifetime'visionmediabefore adoption5ce1306
line 88why, one step back88 describe 'given wildcards'Merge branch 'async-cache'visionmediabefore adoption7606f1b
lines 89–100why, one step back89 it 'should pass a set of caches'90 var result91 store.set('user:1', 'a', function(){92 store.set('user:2', 'b', function(){93 store.set('foo', 'bar', function(){94 store.get('user:*', function(val){95 result = val96 })97 })98 })99 })100 result.should.eql { 'user:1': 'a', 'user:2': 'b' }Added "session reap threshold" settingvisionmediabefore adoptionfa37e5a
line 101why, one step back101 endMerge branch 'cache-lifetime'visionmediabefore adoption5ce1306
lines 102–107why, one step back102 end103 end104 105 describe '#clear()'106 describe 'given a key'107 it 'should delete previous data'Merge branch 'async-cache'visionmediabefore adoption7606f1b
lines 108–116why, one step back108 var result109 store.set('foo', 'bar', function(){110 store.clear('foo', function(){111 store.get('foo', function(val){112 result = val113 })114 })115 })116 result.should.be_nullAdded "session reap threshold" settingvisionmediabefore adoptionfa37e5a
lines 117–119why, one step back117 end118 end119 Merge branch 'cache-lifetime'visionmediabefore adoption5ce1306
lines 120–121why, one step back120 describe 'given wildcards'121 it 'should clear a set of caches'Merge branch 'async-cache'visionmediabefore adoption7606f1b
lines 122–135why, one step back122 var results = []123 store.set('user:one', '1', function(){124 store.set('user:two', '2', function(){125 store.clear('user:*', function(){126 store.get('user:one', function(val){127 results.push(val)128 store.get('user:two', function(val){129 results.push(val)130 })131 })132 })133 }) 134 })135 results.should.eql [null, null]Merge branch 'cache-lifetime'visionmediabefore adoption5ce1306
lines 136–142why, one step back136 end137 end138 end139 140 describe '#reap()'141 it 'should destroy caches older than the given age in milliseconds'142 store.set('user:one', '1')Merge branch 'async-cache'visionmediabefore adoption7606f1b
line 143why, one step back143 store.data['user:one'].created = Number((5).minutes.ago)Merge branch 'cache-lifetime'visionmediabefore adoption5ce1306
line 144why, one step back144 store.set('user:two', '2')Merge branch 'async-cache'visionmediabefore adoption7606f1b
lines 145–152why, one step back145 store.data['user:two'].created = Number((2).seconds.ago)146 store.reap((1).minute)147 store.get('user:one', function(val){148 val.should.be_null149 })150 store.get('user:two', function(val){151 val.should.not.be_null152 })Merge branch 'cache-lifetime'visionmediabefore adoption5ce1306
line 153why, one step back153 endAdded "session reap threshold" settingvisionmediabefore adoptionfa37e5a
lines 154–156why, one step back154 end155 end156end