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 🙏

© 2024 – Pkg Stats / Ryan Hefner

openwhisk-cache-redis

v0.0.6

Published

An Openwhisk action exposing a cache interface with Redis

Downloads

7

Readme

experimental-openwhisk-cache-redis

STATUS: WORK IN PROGRESS

An Openwhisk action exposing a cache interface with Redis. It is designed to expose a simple key,value interface so that the cache store can be replaced with another store, when needed.

In order to avoid key collision the action using a prefix for the keys. I.e. for a key foo, the actual Redis key will be <prefix>:foo. The <prefix> is generated from Openwhisk namespace API KEY (MD5(process.env.__OW_API_KEY)).

Usage

Install the action

$ wsk package create cache # optional
$ wsk action create cache/redis ./openwhisk-cache-redis-0.0.1.js \
        --param host redis_host \
        --param auth redis_auth \
        --param max_ttl <ttl> \
        --param encrypt <true|false>
        --param context object>
  • redis_host - Redis hostname
  • redis_auth - Redis authentication
  • (Not Implemented Yet).max_ttl - default Redis TTL for each key
  • (Not Implemented Yet).encrypt - specifies whether the action should encrypt the values
  • context - an object that is passed in the response. It's usually used in sequences, in order to pass transient information from an action to another. In this case the action doesn't do anything with the context object, and it passes it through, for another action.

Caching key,value pairs

$ wsk action invoke cache/redis --param key my:first:key --param value hello-world
  • key parameter is a string used as the Redis key
  • value parameter is a string.

The response of the action should contain the <key,value> pair that has been persisted:

{
    "key": "my:first:key",
    "value": "hello-world"
}
Caching complex values

When the value parameter represents an object, the action assumes it's a dictionary. This dictionary is saved into a hash map in Redis. Each key in the dictionary represents a field in the HMAP; each value in the dictionary is saved as a string.

$ wsk action invoke cache/redis --param key my:complex:key --param value '{"a":1, "b":2, "c":3}'

The action should return:

{
    "key": "my:complex:key",
    "value": {
        "a": 1,
        "b": 2,
        "c": 3
    }
}

Reading cached key,value pairs

$ wsk action invoke cache/redis --param key my:first:key --blocking --result

{
    "key": "my:first:key",
    "value": "hello-world"
}
  • key parameter is a string used as the Redis key

Reading cached complex values

$ wsk action invoke cache/redis --param key my:complex:key --param fields a,c --blocking --result

{
    "key": "my:complex:key",
    "value": {
        "a": "1",
        "c": "3"
    }
}
  • fields parameter is used to retrieve only a subset of the values associated with the key, in case the value saved originally was a dictionary. I.e for the saved value of {"a":1, "b":2, "c":3}, if fields=a,c, then the response contains only {"a":1, "c":3}

Performing bulk operations

For bulk operations the items parameter should contain the list of operations. For example, to set multiple <key,value> pairs use:

{
  "items": [
      {
        "key": "key-1",
        "value": "value-1"
      },
      {
        "key": "key-2",
        "value": "value-2"
      }
    ]
}

Usage:

$ wsk action invoke cache/redis --param-file items.json