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
 end
 
  attr_reader ​:redis​, ​:logger
 
 def​ ​get_all
  redis.​ ...

Get Build Chatbot Interactions now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.