
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
gulp-memory-cache
Advanced tools
A gulp plugin for caching files in memory with incremental build helpers.
It is aimed to be used with Gulp 4, see why: Building with Gulp 4: Incremental builds.
If you are using Gulp 3, you will need to use gulp-memory-cache
in combination with gulp-cached
or similar.
However be aware that both modules will maintain their own cache and therefore files are cached twice.
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var concat = require('gulp-concat');
var cache = require('gulp-memory-cache');
gulp.task('buildJs', function () {
return gulp.src('src/**/*.js', {since: cache.lastMtime('js')})
.pipe(jshint())
.pipe(cache('js'))
.pipe(concat('app.js'))
.pipe(dest('build'));
});
gulp.task('watch', function () {
gulp.watch('src/**/*.js', gulp.series('buildJs'))
.on('change', cache.update('js'));
});
gulp.task('build', gulp.series('buildJs', 'watch'));
name
(required): the cache namesave
(optional, default to true
): whether or not to save / update cacheIf save
is truthy, it will save (update) streamed files to cache with name name
.
cache()
then returns a stream containing all files in cache in the order they were added.
name
(required): the cache nameSaves streamed files to cache with name name
. Useful if you want to save
in a pipeline for retrieving later (in the same or another pipeline).
name
(required): the cache nameFlush (remove all files) cache name
. Handy to force a stream to process again all its files.
name
(required): the cache namefilePath
(required): the file pathfn
: a file path transformation functionRemove from cache name
file with path filePath
. fn
is a file path transformation function (see below for
an example with cache.update()
.
name
(required): the cache namefn
: a file path transformation functionTo use in watch.on('change', ...)
in order to avoid boilerplate code. It will automatically remove files which have
been deleted from cache name
. fn
is a function to transform a file path and can be useful for removing
a file from cache which name has been altered by a gulp plugin.
gulp.watch('src/**/*.tpl.html', gulp.series('bundlePartials'))
.on('change', cache.update('partials', function (filePath) {
return filePath.replace(/.html$/, '.js')
}));
name
(required): the cache nameReturns the most recent mtime (modified time) of all files in specified cache, can be used in lieu of gulp.lastRun()
.
name
(required): the cache nameReturns the last time a cache was updated, can also be used in lieu of gulp.lastRun()
.
name
(optional): the cache nameReturn cache named name
, or all cached data if name
is not supplied.
cache.get(cacheName)
returns a Cache object.
[0.3.0] - 2015-10-13
.flush(cacheName)
method.FAQs
A gulp plugin to cache files in memory
We found that gulp-memory-cache demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.