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

vemdalen-index

v2.0.2

Published

A simple index which will be persisted in redis

Downloads

26

Readme

Build Status

Vemdalen Index

This is an wrapper for the redis key/value store. It simplifies the interface to the datastore to be able to handle different types of data without to much headache. It will also handle data prefixes/namepaces and this makes it possible to easily separate and isolate your data into different data domains.

The only thing you need to know is what type of data to store. The default is a string list which supports multiple values being stored with the same key. The other datatypes which are supported are pure string and Object.

Create the index instance by simply requiring the module and create a new instance of the object. The instance creation will take a namespace and connection configuration as arguments.

You can supply your own redis client by setting the client config parameter.

After the index instance has been created you can use the put, get and search methods to modify the index.

Configuration

  • client: Set this value if you want to use your own redisClient
  • host (localhost): If client not set, then a new client will connect to this host
  • port (6379): If client not set, then a new client will connect to this port
  • namespace (): This will be the prefix for the indexed items in the redis data store
  • indexType ('strings'): The type if the values to store in the index
    • strings: List of string on a single key, can have duplicate values
    • strings_unique: List of unique strings on a single key, This will slow down the put operation since it has to load the values for the key to match with the new value.
    • string: One string value per key, a set operation will replace the current value
    • object: One object value per key, the object must be a single level hierarchy

Method description

  • clear(): This method will clear all keys and values in the index.
  • put(key, value): The first argument to the put method is the key and the second is the value. If string lists are used then the value will be pushed to the list. If using string or objects are used then the previous value will be overwritten.
  • get(key): Return the value for the given key
  • delete(key): Delete a given key and its value from the index.
  • update(key, value): Will first delete the key and then set the new value for the key.
  • search(pattern): Will return the keys for the matching pattern. To get the value you need to call get for each and every of them.
  • keys(): Returns all the keys in the index
  • size(): Return the number of keys

External dependencies

Nothing else than the Redis data store and the npm redis client.

Why Vemdalen?

Vemdalen is a small and family friendly ski resort in the middle of Sweden. In the beginning of February 2018 I spent a week here with some friends. Out skiing downhill and cross country during the days and playing games and coding during the evenings. I started to think of a wrapper for redis to simplify get and set functionality and migrating the interface from my other index to this.