Store Scheduled Tasks in Redis

This module crystallizes the core requirements of the scheduler:

  • Add a specific task to the schedule datastore with a specific future timestamp, for example, “double 2,” “in 4 minutes.”

  • Check the schedule datastore to see whether any tasks have past-due timestamps.

You need to set the stage for storing tasks with a new Lita::Scheduler class that announces its intent to work with a specific Redis hash data structure stored in a location with a relevant name.

 module​ ​Lita
 class​ Scheduler
  REDIS_TASKS_KEY = name.​to_s
 def​ ​initialize​(redis:, logger:)
  @redis = redis
  @logger = logger
  attr_reader ​:redis​, ​:logger
 def​ ​get_all
  redis.​ ...

Get Build Chatbot Interactions now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.