1+ exports . install = function ( framework ) {
2+ framework . route ( '/' , view ) ;
3+ framework . route ( '/json/' , json ) ;
4+ framework . route ( '/plain/' , plain ) ;
5+ } ;
6+
7+ function view ( ) {
8+
9+ var self = this ;
10+ self . repository . ticks = new Date ( ) . getTime ( ) ;
11+
12+ // Save a rendered HTML into the cache (only the view - without layout, layout is not cached)
13+ // Documentation: http://docs.totaljs.com/FrameworkController/#controller.memorize
14+ // Memorize uses standard internal FrameworkCache
15+ self . memorize ( 'view' , new Date ( ) . add ( 'minute' , 2 ) , function ( ) {
16+ self . view ( 'homepage' , self . repository . ticks ) ;
17+ } ) ;
18+
19+ }
20+
21+ function json ( ) {
22+
23+ var self = this ;
24+
25+ // Save a generated JSON into the cache
26+ // Documentation: http://docs.totaljs.com/FrameworkController/#controller.memorize
27+ // Memorize uses standard internal FrameworkCache
28+ self . memorize ( 'json' , new Date ( ) . add ( 'minute' , 2 ) , function ( ) {
29+ self . json ( { ticks : new Date ( ) . getTime ( ) } ) ;
30+ } ) ;
31+ }
32+
33+ function plain ( ) {
34+
35+ var self = this ;
36+
37+ // Save a output into the cache
38+ // Documentation: http://docs.totaljs.com/FrameworkController/#controller.memorize
39+ // Memorize uses standard internal FrameworkCache
40+ self . memorize ( 'plain' , new Date ( ) . add ( 'minute' , 2 ) , function ( ) {
41+ self . plain ( 'ticks: ' + new Date ( ) . getTime ( ) ) ;
42+ } ) ;
43+ }
0 commit comments