npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

azurecache

v0.1.0

Published

Winows Azure Cache client and Express session store

Downloads

10

Readme

Access Windows Azure Cache Service from Node.js

The azurecache module allows you to use the Windows Azure Cache Service to store session state in Express applications. It also allows direct access to Windows Azure Cache Service from other Node.js applications.

The azurecache module uses Edge.js and as such it currently only works on Windows. It is a great fit for storing session state of Express applications hosted in Windows Azure Web Sites. It is also a good choice for any other type of Node.js application hosted in Windows Azure that requires caching.

Express session state

First create your Windows Azure Cache Service instance following insturctions at Scott Guthrie's blog. You will end up with an endpoint URL of your cache service (e.g. tjanczuk.cache.windows.net) and an access key (a long Base64 encoded string).

Then install the azurecache and express modules:

npm install azurecache
npm install express

Next author your Express application that uses the azurecache module to store Express session state in the Windows Azure Cache Service:

var express = require('express')
    , AzureCacheStore = require('azurecache')(express);

var app = express();

app.use(express.cookieParser());
app.use(express.session({ store: new AzureCacheStore(), secret: 'abc!123' }));

app.get('/inc', function (req, res) {
    req.session.counter = (req.session.counter + 1) || 1;
    res.send(200, 'Increased sum: ' + req.session.counter);
});

app.get('/get', function (req, res) {
    res.send(200, 'Current sum: ' + req.session.counter);
});

app.listen(process.env.PORT || 3000);

Lastly set some environment variables and start your server:

set AZURE_CACHE_IDENTIFIER=<your_azure_cache_endpoint_url>
set AZURE_CACHE_TOKEN=<your_azure_cache_access_key>
node server.js

Every time you visit http://localhost:3000/inc in the browser you will receive an ever increasing counter value. When you visit http://localhost:3000/get you will receive the current counter value. The value of the counter is stored as part of the Express session state in the Windows Azure Cache Service with a default TTL of one day.

Customize Express session state

You can specify the credentials to the Windows Azure Cache Service either in code or via environment variables:

var azureCacheOptions = {
    identifier: '<your_endpoint_url>', // or set the AZURE_CACHE_IDENTIFIER environment variable
    token: '<your_access_key>', // or set the AZURE_CACHE_TOKEN environment variable
    ttl: 3600 // optional TTL in seconds (default 1 day); or set the AZURE_CACHE_TTL env variable
};

// ...

app.use(express.session({ store: new AzureCacheStore(azureCacheOptions), secret: 'abc!123' }));

Use Windows Azure Cache Service directly

You can access Windows Azure Cache Service directly too:

var azurecache = require('azurecache')

var cache = azurecache.create({
    identifier: '<your_endpoint_url>', // or set the AZURE_CACHE_IDENTIFIER environment variable
    token: '<your_access_key>', // or set the AZURE_CACHE_TOKEN environment variable
    ttl: 3600 // optional TTL in seconds (default 1 day); or set the AZURE_CACHE_TTL env variable
});

cache.put('test1', { first: 'Tomasz', last: 'Janczuk' }, function (error) {
    if (error) throw error;
    cache.get('test1', function (error, data) {
        if (error) throw error;
        console.log('Data from cache:', data);
    });
});

How

The azurecache module uses Edge.js to access the .NET client of the Windows Azure Cache Service that ships as a NuGet package. The gist of the idea is here.

More

I do take contributions. Feedback welcome (file an issue). Enjoy!