Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
azurecache
Advanced tools
Readme
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.
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.
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' }));
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);
});
});
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.
I do take contributions. Feedback welcome (file an issue). Enjoy!
FAQs
Winows Azure Cache client and Express session store
The npm package azurecache receives a total of 1 weekly downloads. As such, azurecache popularity was classified as not popular.
We found that azurecache 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.