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

codic-redis

v2.0.0

Published

Redis database driver for codic job scheduling

Downloads

12

Readme

Codic Redis

A redis database driver for Codic task scheduler. Use codic-redis as the driver for scheduling jobs with Codic.

New to Codic? Codic allows you to create javascript jobs for any database you are using. No need to install a separate database for managing automated jobs. Read more here.


Content

  1. About Codic
  2. Installation
  3. Release Info
  4. Usage
  5. Configuring redis Connection
  6. Configuring redis Server
  7. Documentation

About codic

Codic uses Activities and Tasks to let you automate processes in your app.

A task is what you want to do at a particular time. It can be a simple function or a file exporting a function.

Activity specifies the time and how often one or more tasks are run. It can run one or more tasks, it can be updated at runtime.

You can store the tasks and activities using any database through its drivers interface. codic-redis is a driver implementation for redis database.

Installation

Install codic and codic-redis.

npm install --save codic codic-redis

or

yarn add codic codic-redis

Release Info

codic-redis is now version 2, with typescript support just like codic. Note: your app does not have to be in typescript to use the library.

Usage

In your code, do the following:

import Codic from "codic";
import RedisDriver from "codic-redis";

//instatiate redis driver and codic
var driver = new RedisDriver();
var codic = new Codic(driver);

// define your tasks
const simpleLogTask = (activity) => {
    console.log("Simply saying "+activity.attrs.data.message);
}
// use an IIFE, to create database activities
(async function(){

    try {
        // register task on Codic
        await codic.assign("log something",{},simpleLogTask);

        //create the activities that run the tasks
        await codic
            .run("log something")
            .every(3) //3 seconds
            .use({ message: "Hello" }) //pass data to task
            .save();

        //start codic
        await codic.start();
    } catch (error) {
    console.log(error);
  }
})();

Thats it. You are live!!

Remember to start your redis server for this to work.

Configuring redis Connection

codic-redis uses ioredis under the hood. You would configure it the same way you configure ioredis. ioredis is a robust, performance-focused and full-featured Redis client for Node.js.

On instantiation, pass your configuration object to the RedisDriver like below:


var driver = new RedisDriver({
  port: 6379,          // Redis port
  host: '127.0.0.1',   // Redis host
  family: 4,           // 4 (IPv4) or 6 (IPv6)
  password: 'auth',
  db: 0
});

Once this is running, you have access to the underlying ioredis object via

driver.db

All of ioredis actions can be performed on the driver.db object. You can follow the ioredis documentation here.

Configuring redis server

Redis requires a server to be running on your host computer. It is recommended that you use redis version >4.0.0.

Linux users can download it from their package manager though that might be out of date.

Make sure your redis server is running on the same port as you specify in the redis configuration above.

Documentation

Click here for Codic documentation.