Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

s3asy

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

s3asy - npm Package Compare versions

Comparing version 0.4.0 to 0.4.1

20

index.js

@@ -28,7 +28,21 @@ var knox = require('knox'),

var _get = function() {
var _get = function(path, headers) {
self.client.get(path, headers).on('response', function(res) {
if (res.statusCode === 304) {
return cache.get(path, callback);
return cache.get(path, function(err, data) {
if (err) return callback(err);
if (!data) {
// We need to bust the cache here. The data was cleared out of redis already,
// but S3 think's it wasn't modified.
cache.delete(path+'-date', function(err) {
if (err) return callback(err);
delete headers['If-Modified-Since'];
self.get(path, headers, callback);
});
}
});
}
if (res.statusCode != 200) {

@@ -69,3 +83,3 @@ return callback(new Error('ERROR: status code = '+res.statusCode));

if (date) headers['If-Modified-Since'] = date;
_get();
_get(path, headers);
});

@@ -72,0 +86,0 @@ }

4

package.json

@@ -5,3 +5,3 @@ {

"description": "Simple S3 integration with a cache backed by Redis",
"version": "0.4.0",
"version": "0.4.1",
"repository": {

@@ -17,3 +17,3 @@ "type": "git",

"knox" : "*",
"cacheit": "*",
"cacheit": ">=0.3.0",
"async": "*",

@@ -20,0 +20,0 @@ "sax": "*"

@@ -51,3 +51,47 @@ var S3 = require('../index');

it('can save and retrieve the original content again', function(done) {
// Reset the default ttl to 10 sec
s3.cache.default_ttl = 10;
s3.put('/test/s3asy', {
'Content-Type': 'text/plain',
'Content-Length': original.length
}, original, function(err) {
assert.ok(!err);
s3.get('/test/s3asy', function(err, data) {
assert.ok(!err);
assert.equal(data, original);
done();
});
});
});
it('can successfully bust the cache', function(done) {
s3.cache.delete('/test/s3asy', function(err) {
assert.ok(!err);
// Data is no longer in cache
s3.cache.get('/test/s3asy', function(err, data) {
assert.ok(!err);
assert.deepEqual(data, undefined);
// Last modified date is still in the cache
s3.cache.get('/test/s3asy-date', function(err, data) {
assert.ok(!err);
assert.ok(data);
// Ensure the cache was busted by getting data back from S3 and not
// undefined from the cache
s3.get('test/s3asy', function(err, data) {
assert.ok(!err);
assert.deepEqual(data, original);
done();
});
});
});
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc