New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

appc-cache

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

appc-cache

AppC cache client library

  • 0.0.2
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

Appcelerator Cache Client library Build Status

The library makes it easy to use the Appcelerator Cache API Service. This library is meant to act as a drop-in replacement for the Node Redis Client Library.

Installation

npm install appc-cache --save

Usage

You must first include the library and create an instance. At a minimum, you must pass in the key and secret values for constructing the client.

var Cache = require('appc-cache'),
    cache = new Cache({
        key: 'MY_KEY',
        secret: 'MY_SECRET'
    });

Once you have created the client instance, you can use it. This library is (generally) compatible with the Redis API.

cache.set('key', 'value', function (err) {
    // set the value
});

cache.get('key', function (err, value) {
    console.log('cached value is', value);
});

Redis Client emulation

This library emulates the same API as the redis client. For example:

var redis = require('appc-cache');
var client = redis.createClient({
    key: 'key'
});
client.auth('secret');
var multi = client.multi();
multi.echo('OK', redis.print);
multi.exec();

Using as an Express Session Store

This library provides an Express compatible session store implementation. Example usage:

var app = express(),
    session = require('express-session'),
    Cache = require('appc-cache'),
    CacheStore = Cache.createSessionStore(session),
    options = {
        key: 'mykey',
        secret: 'mysecret',
        ttl: 2000
    };
app.use(session({
    store: new CacheStore(options),
    secret: 'keyboard cat',
    resave: false,
    saveUninitialized: false
}));

Using Distributed Locks

This library supports distributed locks. With a distributed lock, only one client can acquire a named lock at a time for a specified duration.

cache.lock('my.lock', 10000, function (err, lock) {
    cache.unlock(lock);
});

You can extend the lock with the extend method. For example:

cache.lock('my.lock', 10000, function (err, lock) {
    // extend the lock another 10 sec
    cache.extend(lock, 10000);
    cache.unlock(lock);
});

APIs that are not supported

There are a number of APIs that are not support or not allowed. For example, this library does not support shutdown. For a full list of commands, see the file lib/blacklist.js.

Running the Unit Tests

You can run the unit tests by setting the value of the following environment variables APPC_TEST_KEY and APPC_TEST_SECRET to the values to use for caching. For example:

APPC_TEST_KEY=kkkkkkkkkkkkkkkkkkkkkkkkk APPC_TEST_SECRET=ssssssssssssssssssssssss grunt

License

The library is Confidential and Proprietary to Appcelerator, Inc. and licensed under the Appcelerator Software License Agreement. Copyright (c) 2015 by Appcelerator, Inc. All Rights Reserved.

Keywords

FAQs

Package last updated on 04 Sep 2015

Did you know?

Socket

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.

Install

Related posts

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