1.0.12 • Published 4 years ago

cactus-stl v1.0.12

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

cactus-stl

Standard library for CactusDev TypeScript projects

Usage

Using RedisController

import { RedisController } from "cactus-stl";

async function setup() {
    // Create the redis handler
    const handler = new RedisController({
        db: 0,
        host: "localhost",
        port: 6379,
        password: "awesome_password"
    });

    // Connect to redis
    await handler.connect();
    console.log("Connected to Redis!");

    // Set and get
    await handler.set("foo", "bar");
    console.log("Value of foo: " + await handler.get("foo"));

    // Can also set expiration
    await handler.set("potato", "salad", 100);

    // Pub / Sub is built right into the handler!
    // You can also use .unsubscribe, which only takes the channel.
    await handler.subscribe("cool_channel", (message: string) => {
        console.log("Got a really cool message!", message);
    });

    await handler.publish("cool_channel", "Hello world!");

    // Delete
    await handler.delete("foo");

    // Increment a variable
    await handler.increment("potato");

    // Make sure to disconnect!
    await handler.disconnect();
}

setup();
1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago