Skip to content

SC5/aws-document-cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aws-document-cache NPM module

A module for implementing a simple in-memory and DB cache for 3rd party datasources using AWS DynamoDB

Prerequisites

A DynamoDB table with a primary key "cacheKey" of type "String" AWS credentials as required by aws-sdk module (e.g. ~/.aws/credentials)

Use example

var cache = require("aws-document-cache");
cache.init({
            'awsRegion' : 'eu-west-1',             # Region where the table resides
            'cacheTable' : 'myDynamoDBTable',      # Table for the cache
            'memCacheLifetime' : 3600 * 1000,      # Lifespan in ms for the memory cache entries
            'dbCacheLifetime' : 24 * 3600 * 1000,  # Lifespan in ms for the db cache entries
            });
            
cache.getDoc('myObjType', 'myObjId', function(err,data) {
    if (err) {
        ...
    }
    if (data == null) {
        ... was not found in cache, load it
    }
});

cache.setDoc('myObjType', 'myObjId', data, function(err, data) {
    if (err) {
        ... storage failed
    }
    ...
}

Release History

  • 2015/07/21 - v0.0.1 - Initial version of module
  • 2015/07/22 - v0.0.2 - BUGFIX: old references to promise style callbacks removed
  • 2015/07/22 - v0.0.3 - BUGFIX: old references to promise style callbacks removed
  • 2015/12/28 - v0.0.5 - Cleaned temp files generated by emacs. Changed dynamodb-doc -> aws-sdk.
  • 2016/02/03 - v0.0.6 - Fix memCacheLifetime parameter

License

Copyright (c) 2015 SC5, licensed for users and contributors under MIT license. https://github.com/SC5/aws-document-cache/blob/master/LICENSE

Bitdeli Badge

About

Generic document cache based on DynamoDB

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published