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

@tree-key-cache/redis-storage

v0.1.8

Published

avro tree serializer fot tree-key-cache

Downloads

2

Readme

Actions Status Actions Status Actions Status Test Coverage Maintainability Packages npm version

Redis storage implementations for tree-key-cache

How to Install

npm i @tree-key-cache/redis-storage

How to use it

This library offers three implementation flavors:

Simple Redis Storage

This is the most straight forward one, the one aiming to attend the most cases: just a simple get and set proxy. You also have a randomIterate implementation ready to go, and optional getChildren and registerChild implementations using sadd and sscan to control key level keys children. To use it without children registration:

const storage = new TreeKeyCacheSimpleRedisStorage({
  host: 'my-redis-host',
  treeDb: 1,
})

To use it with children registration:

const storage = new TreeKeyCacheSimpleRedisStorage({
  host: 'my-redis-host',
  treeDb: 1,
  childrenDb: 2,
  childrenRegistry: true,
})

Insert Only Redis Storage

This is a key history enabled implementation, ideal if you need to keep every registered value for a key separated. Aside from all the functionalities that TreeKeyCacheSimpleRedisStorage delivers, it also implement getHistory, which will return every single non expired value of the given key, from the latest to the oldest. Although we don't explicit control it, this implementation assumes that older keys expire first, so, be aware that, if you have N keys registered and, for some reason, a key in the middle of the way is evicted, getHistory will not yield the keys older than it. Also be aware of the memory of your instance, as this implementation tends to consume much more than the simple one. We recommend you to practice low ttl when using it.

To use it:

const storage = new TreeKeyCacheSimpleRedisStorage({
  host: 'my-redis-host',
  treeDb: 1,
  childrenDb: 2,
  childrenRegistry: true, // optional
})

Timed round robin Redis Storage

This is a key history enabled implementation that is in the middle of the way between the insertOnly and the simple one. With this one, you can have a redis db pool to control key history. Based on a measure of day, a redis db is set as the current one, making all the new persistence being written in it. This will make older versions of each key to be stored in the other redis versions, making it possible to recover the history, also ordered from the latest to the oldest. The redis db pool can use dbs from the same main host, or even from totally separated redis instances! The only drawback is that, if you want children registry, this will be controlled in a single redis db instance: the main one.

To use it:

const storage = new TreeKeyCacheTimedRoundRobinRedisStorage({
  host: 'my-main-redis-host',
  treeDbPool: [1, 2, 3, {
    host: 'another-redis-host',
    dbs: [1, 2, 3, 4]
  }],
  childrenDb: 16,
  childrenRegistry: true, // optional
  // Db timed round trip will use this as the base date for db change
  baseTimestamp: new Date('2023-10-01T00:00:00Z').getTime(),
  // How many days does it take to change db, ie, every db will be the main one for 7 days
  dayScale: 7,
})

License

Licensed under MIT.