concept cache in category javascript

appears as: caches, The cache, cache, cache
Front-End Tooling with Gulp, Bower, and Yeoman

This is an excerpt from Manning's book Front-End Tooling with Gulp, Bower, and Yeoman.

Figure 6.5. With the gulp-cached plugin, all files are selected from your original JavaScript files. The cache then checks to see if the files are already in the cache. If not, they’ll be passed through to the stream and also added to your designated cache. If they’re already in the cache, cached checks to see if the files from your selection are newer than the ones in the cache. If so, they will be passed through and updated to your cache. If not, they will be discarded from the stream.
Single Page Web Applications: JavaScript end-to-end

This is an excerpt from Manning's book Single Page Web Applications: JavaScript end-to-end.

  • In the lower-right corner of the screen is a gears icon: click on that and see some advanced developer options such as disabling cache and turning on logging of XmlHttpRequests.
  • Listing 9.7. Reading from the cache—webapp/lib/crud.js
    /* * crud.js - module to provide CRUD db capabilities */ ... // ------------ BEGIN MODULE SCOPE VARIABLES -------------- 'use strict'; var ... JSV = require( 'JSV' ).JSV, cache = require( './cache' ), #1 mongoServer = new mongodb.Server( ... // ------------- END MODULE SCOPE VARIABLES --------------- ... // ---------------- BEGIN PUBLIC METHODS ------------------ ... readObj = function ( obj_type, find_map, fields_map, callback ) { var type_check_map = checkType( obj_type ); if ( type_check_map ) { callback( type_check_map ); return; } cache.getValue( find_map, callback, function () { #2 #3 dbHandle.collection( obj_type, function ( outer_error, collection ) { #4 collection.find( find_map, fields_map ).toArray( #4 function ( inner_error, map_list ) { #4 cache.setValue( find_map, map_list ); #4 callback( map_list ); #4 } ); } ); }); $5 }; ... destroyObj = function ( obj_type, find_map, callback ) { var type_check_map = checkType( obj_type ); if ( type_check_map ) { callback( type_check_map ); return; } cache.deleteKey( find_map ); #6 dbHandle.collection( obj_type, function ( outer_error, collection ) { var options_map = { safe: true, single: true }; collection.remove( find_map, options_map, function ( inner_error, delete_count ) { callback({ delete_count: delete_count }); } ); } ); }; ... // ----------------- END PUBLIC METHODS ------------------- ... #1 Include the cache module in our CRUD module. #2 Add a cache.getValue call, and pass the previous call to mongo in the callback to be executed in case of a cache miss. #3 Use find_map as our cache key. #4 Add the item to the cache with a call to cache.setValue when there’s a cache miss. $5 Remove the search key from Redis using the cache.deleteKey method when we delete an object from the database. !@%STYLE%@! {"css":"{\"css\": \"font-weight: bold;\"}","target":"[[{\"line\":28,\"ch\":0},{\"line\":28,\"ch\":37}]]"} !@%STYLE%@!