Skip to content
Myr

Pre-caching views in memory. Closes #253

Before adoption: this commit came in with the history the project adopted, so no landing records it.

This mirrors the partial caching functionality. This causes a slight overhead at boot time, however prevents the need to perform cache checks per render() call.

authored by visionmedia · committed by visionmedia · parent c29852f · Browse files · 2 files+9 added−46 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+9 added−46 removed

  • tests:+0 added−20 removed
  • other:+9 added−26 removed

2 files+9 added−46 removed

modified:lib/express/plugins/view.js+9 added-26 removed
modified:spec/spec.plugins.view.js-20 removed
119 unmodified lines
120 get('/').body.should.include '<h2>Hello'121 end122 end123 124 describe 'when "cache view contents" is enabled'125 it 'should read the views into memory only once'126 enable('cache view contents')127 get('/', function(){128 this.render('hello.haml.html')129 })130 get('/cached', function(){131 var self = this132 this.cache.get('view:spec/fixtures/hello.haml.html', function(val){133 self.halt(200, val ? 'yes' : 'no')134 })135 })136 get('/cached').body.should.eql 'no'137 get('/')138 get('/cached').body.should.eql 'yes'139 get('/')140 get('/cached').body.should.eql 'yes'141 end142 end143 124 describe 'when engine cannot be found'125 it 'should throw an error'126 get('/', function(){127 this.render('user.invalid.html')
53 unmodified lines