Skip to content

Commit

Permalink
more support for local cache as the default cache
Browse files Browse the repository at this point in the history
  • Loading branch information
chelm committed Mar 2, 2015
1 parent 602981c commit acb4504
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/Local.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ module.exports = {

// get data out of the store
select: function(key, options, callback){

if (options.layer || options.layer === 0) {
key = key+':'+options.layer;
}

if ( !this.store[ key ] ){
callback('Not Found', []);
} else if (this.store[ key ] && this.store[ key ].info && this.store[ key ].info.status == 'processing' && !options.bypassProcessing ) {
Expand Down
4 changes: 3 additions & 1 deletion test/models/cache.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
var should = require('should');

var Cache;

before(function (done) {
key = 'test:repo:file';
repoData = require('../fixtures/repo.geojson');
Expand Down Expand Up @@ -44,7 +46,7 @@ describe('Cache Model Tests', function(){
Cache.insert( 'repo', key, repoData[0], 0, function( error, success ){
should.not.exist(error);
success.should.equal( true );
Cache.get('repo', key, {}, function( err, d ){
Cache.get('repo', key, { layer: 0 }, function( err, d ){
should.not.exist(err);
should.exist(d[0].name);
d[0].name.should.equal('forks.geojson');
Expand Down
49 changes: 49 additions & 0 deletions test/test.log
Original file line number Diff line number Diff line change
Expand Up @@ -952,3 +952,52 @@
{"level":"info","message":"Removed Bucket from s3 subdir %s","timestamp":"2015-02-11T21:46:31.884Z"}
{"level":"debug","message":"Delete subdir subdir/test2.json","timestamp":"2015-02-11T21:46:31.889Z"}
{"level":"info","message":"File does not exist on S3 chelm-koop-shoot-local subdir test2.json","timestamp":"2015-02-11T21:46:32.396Z"}
{"level":"info","message":"File does not exist on S3 chelm-koop-shoot-local null dummy.png","timestamp":"2015-02-17T14:29:07.625Z"}
{"level":"info","message":"Uploaded file to s3 chelm-koop-shoot-local/ test.json","timestamp":"2015-02-17T14:29:10.693Z"}
{"level":"info","message":"File exists on S3 chelm-koop-shoot-local test.json","timestamp":"2015-02-17T14:29:11.296Z"}
{"level":"info","message":"Uploaded file to s3 chelm-koop-shoot-local/test test.json","timestamp":"2015-02-17T14:29:12.777Z"}
{"level":"info","message":"File exists on S3 chelm-koop-shoot-local test.json","timestamp":"2015-02-17T14:29:13.393Z"}
{"level":"info","message":"Uploaded file to s3 chelm-koop-shoot-local//test-rm test-rm.json","timestamp":"2015-02-17T14:29:14.824Z"}
{"level":"info","message":"Removed file from s3 chelm-koop-shoot-local test-rm.json","timestamp":"2015-02-17T14:29:15.483Z"}
{"level":"info","message":"File does not exist on S3 chelm-koop-shoot-local /test-rm test-rm.json","timestamp":"2015-02-17T14:29:16.135Z"}
{"level":"info","message":"Uploaded file to s3 chelm-koop-shoot-local/subdir test2.json","timestamp":"2015-02-17T14:29:17.652Z"}
{"level":"debug","message":"Delete subdir subdir/test2.json","timestamp":"2015-02-17T14:29:19.704Z"}
{"level":"info","message":"Removed Bucket from s3 subdir %s","timestamp":"2015-02-17T14:29:19.705Z"}
{"level":"info","message":"File does not exist on S3 chelm-koop-shoot-local subdir test2.json","timestamp":"2015-02-17T14:29:20.423Z"}
{"level":"info","message":"File does not exist on S3 chelm-koop-shoot-local null dummy.png","timestamp":"2015-02-17T14:29:59.505Z"}
{"level":"info","message":"Uploaded file to s3 chelm-koop-shoot-local/ test.json","timestamp":"2015-02-17T14:30:03.988Z"}
{"level":"info","message":"File exists on S3 chelm-koop-shoot-local test.json","timestamp":"2015-02-17T14:30:05.559Z"}
{"level":"info","message":"Uploaded file to s3 chelm-koop-shoot-local/test test.json","timestamp":"2015-02-17T14:30:06.877Z"}
{"level":"info","message":"File exists on S3 chelm-koop-shoot-local test.json","timestamp":"2015-02-17T14:30:07.507Z"}
{"level":"info","message":"Uploaded file to s3 chelm-koop-shoot-local//test-rm test-rm.json","timestamp":"2015-02-17T14:30:09.791Z"}
{"level":"info","message":"Removed file from s3 chelm-koop-shoot-local test-rm.json","timestamp":"2015-02-17T14:30:10.296Z"}
{"level":"info","message":"File does not exist on S3 chelm-koop-shoot-local /test-rm test-rm.json","timestamp":"2015-02-17T14:30:10.880Z"}
{"level":"info","message":"Uploaded file to s3 chelm-koop-shoot-local/subdir test2.json","timestamp":"2015-02-17T14:30:12.095Z"}
{"level":"debug","message":"Delete subdir subdir/test2.json","timestamp":"2015-02-17T14:30:13.799Z"}
{"level":"info","message":"Removed Bucket from s3 subdir %s","timestamp":"2015-02-17T14:30:13.802Z"}
{"level":"info","message":"File does not exist on S3 chelm-koop-shoot-local subdir test2.json","timestamp":"2015-02-17T14:30:14.412Z"}
{"level":"info","message":"File does not exist on S3 chelm-koop-shoot-local null dummy.png","timestamp":"2015-02-17T14:31:56.491Z"}
{"level":"info","message":"File does not exist on S3 chelm-koop-shoot-local null dummy.png","timestamp":"2015-02-17T14:39:14.266Z"}
{"level":"info","message":"Uploaded file to s3 chelm-koop-shoot-local/ test.json","timestamp":"2015-02-17T14:39:16.485Z"}
{"level":"info","message":"File exists on S3 chelm-koop-shoot-local test.json","timestamp":"2015-02-17T14:39:17.027Z"}
{"level":"info","message":"Uploaded file to s3 chelm-koop-shoot-local/test test.json","timestamp":"2015-02-17T14:39:18.154Z"}
{"level":"info","message":"File exists on S3 chelm-koop-shoot-local test.json","timestamp":"2015-02-17T14:39:18.661Z"}
{"level":"info","message":"Uploaded file to s3 chelm-koop-shoot-local//test-rm test-rm.json","timestamp":"2015-02-17T14:39:19.739Z"}
{"level":"info","message":"Removed file from s3 chelm-koop-shoot-local test-rm.json","timestamp":"2015-02-17T14:39:20.232Z"}
{"level":"info","message":"File does not exist on S3 chelm-koop-shoot-local /test-rm test-rm.json","timestamp":"2015-02-17T14:39:20.763Z"}
{"level":"info","message":"Uploaded file to s3 chelm-koop-shoot-local/subdir test2.json","timestamp":"2015-02-17T14:39:21.750Z"}
{"level":"info","message":"Removed Bucket from s3 subdir %s","timestamp":"2015-02-17T14:39:23.078Z"}
{"level":"debug","message":"Delete subdir subdir/test2.json","timestamp":"2015-02-17T14:39:23.089Z"}
{"level":"info","message":"File does not exist on S3 chelm-koop-shoot-local subdir test2.json","timestamp":"2015-02-17T14:39:23.534Z"}
{"level":"info","message":"File does not exist on S3 chelm-koop-shoot-local null dummy.png","timestamp":"2015-02-17T14:39:34.807Z"}
{"level":"info","message":"Uploaded file to s3 chelm-koop-shoot-local/ test.json","timestamp":"2015-02-17T14:39:36.819Z"}
{"level":"info","message":"File exists on S3 chelm-koop-shoot-local test.json","timestamp":"2015-02-17T14:39:37.244Z"}
{"level":"info","message":"Uploaded file to s3 chelm-koop-shoot-local/test test.json","timestamp":"2015-02-17T14:39:38.334Z"}
{"level":"info","message":"File exists on S3 chelm-koop-shoot-local test.json","timestamp":"2015-02-17T14:39:38.798Z"}
{"level":"info","message":"Uploaded file to s3 chelm-koop-shoot-local//test-rm test-rm.json","timestamp":"2015-02-17T14:39:39.922Z"}
{"level":"info","message":"Removed file from s3 chelm-koop-shoot-local test-rm.json","timestamp":"2015-02-17T14:39:40.358Z"}
{"level":"info","message":"File does not exist on S3 chelm-koop-shoot-local /test-rm test-rm.json","timestamp":"2015-02-17T14:39:40.810Z"}
{"level":"info","message":"Uploaded file to s3 chelm-koop-shoot-local/subdir test2.json","timestamp":"2015-02-17T14:39:41.802Z"}
{"level":"info","message":"Removed Bucket from s3 subdir %s","timestamp":"2015-02-17T14:39:42.866Z"}
{"level":"debug","message":"Delete subdir subdir/test2.json","timestamp":"2015-02-17T14:39:42.889Z"}
{"level":"info","message":"File does not exist on S3 chelm-koop-shoot-local subdir test2.json","timestamp":"2015-02-17T14:39:43.307Z"}

0 comments on commit acb4504

Please sign in to comment.