@gmetrixr/webdis-commands

0.0.7 • Public • Published

Build Status

webdis-commands

Client library for making webdis server requests

Exposed Commands:

  1. set
  2. get
  3. del
  4. exists
  5. sadd
  6. srem
  7. smember
  8. hset
  9. hget
  10. hmset
  11. hmget
  12. hdel
  13. sismember
  14. mget
  15. flushdb
  16. flushall
  17. ping
  18. publish
  19. unsubscribe

Running example

This repo uses pnpm to run, compile and build code

  1. ./sd - start the docker
  2. p i - install dependencies. p is an alias for pnpm
  3. cd examples
  4. p i - install dependencies for examples
  5. p watch - start dev server. uses Snowpack

Basic Usage

  import Webdis from "@gmetrixr/webdis-commands";
  const options = {
    db: 1, // set db index
    auth: "username:passwd", // optional auth to webdis server
  };
  const url = "http://localhost:8003";
  const webdis = new Webdis(url, options);
  
  // execute commands
  const response = await webdis.command().ping();
  console.log(response); // [true, "PONG"]

Pub/Sub

  import Webdis from "@gmetrixr/webdis-commands";
  const options = {
    db: 1, // set db index
    auth: "username:passwd", // optional auth to webdis server
  };
  const url = "http://localhost:8003";
  const webdis = new Webdis(url, options);
  
  const channel = "process";
  const cb = (data: string | object) => {
    // cb should always test the typeof data here. parsing can result in either text or js objects
  };
  // subcsription
  const id = webdis.subscribe(channel, cb);
  
  // un-subscription
  webdis.unsubscribe(channel, id); // pass the subscription id 

Readme

Keywords

none

Package Sidebar

Install

npm i @gmetrixr/webdis-commands

Weekly Downloads

0

Version

0.0.7

License

UNLICENSED

Unpacked Size

26.2 kB

Total Files

18

Last publish

Collaborators

  • pokerdom
  • sahil87
  • amit.rajput