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

@boardgame.io/storage-cache

v0.6.0

Published

๐Ÿ”Œ A caching layer for boardgame.io database connectors

Downloads

22

Readme

@boardgame.io/storage-cache

NPM Version Test CI Status Coverage Status

๐Ÿ”Œ A caching layer for boardgame.io database connectors

This package provides a wrapper for boardgame.io storage implementations, adding an in-memory cache for the most recently used data.

The cache expects all interactions with the underlying database to pass through it, so it is not appropriate for situations where you may have multiple processes or server instances. There are also limitations to what can be reliably cached: listing all games will always require a call to your database.

Installation

npm install --save @boardgame.io/storage-cache

Usage

Instantiate your database class as usual and pass it to StorageCache. This example uses the flat-file storage solution bundled with boardgame.io.

const { Server, FlatFile } = require('boardgame.io/server');
const { StorageCache } = require('@boardgame.io/storage-cache');
const { MyGame } = require('./game');

// instantiate the database class
const db = new FlatFile({ dir: '/storage/directory' });

// wrap the database with the caching layer
const dbWithCaching = new StorageCache(db, { cacheSize: 200 });

// pass the wrapped database to the boardgame.io server
const server = Server({
  games: [MyGame],
  db: dbWithCaching,
});

server.run(8000);

API

new StorageCache(database[, options])

database

An instance of a class implementing the boardgame.io storage API.

options

  • type: object
  • default: {}

An options object configuring the cache:

{
  /**
   * The number of games to cache in memory.
   * @type {number}
   * @default 1000
   */
  cacheSize: 1000,
}

Contributing

Bug reports, suggestions, and pull requests are very welcome! If you run into any problems or have questions, please open an issue.

Please also note the code of conduct and be kind to each other.

License

The code in this repository is provided under the MIT License.