Redis
Upcoming SlideShare
Loading in...5
×
 

Redis

on

  • 993 views

About redis and how we used to implement stateful widgets in our project of e-learning system ALEF and to allow for background logging with the help of resque.

About redis and how we used to implement stateful widgets in our project of e-learning system ALEF and to allow for background logging with the help of resque.

Statistics

Views

Total Views
993
Views on SlideShare
940
Embed Views
53

Actions

Likes
1
Downloads
11
Comments
0

2 Embeds 53

http://speakerrate.com 44
http://lanyrd.com 9

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Redis Redis Presentation Transcript

  • @robo_moro
  • redis• In-memory key-value store• Master-slave replication• Persistence – RDB (snapshots) – AOF (append-only log file)• Supported languages – Ruby, Python, Java, C, PHP, Javascript (Node.js)
  • redis• Data types – String, List, Set, Hash, Sorted set• Used in – Engine Yard, Github, stackoverflow, …
  • redis• Data types – String, List, Set, Hash, Sorted set• Used in – Engine Yard, Github, stackoverflow, … ALEF
  • ALEF = Adaptive LEarning Framework
  • ALEF stateful widgets• Asynchronous initialization & callbacks• Problem – The action1 servicing widget1 loads the current session – The action2 servicing widget2 loads the current session – action1 makes some changes to its copy of the session – action2 makes some changes to its copy of the session – action2 completes and saves its changed session data – action1 completes and saves its changed session data
  • ALEF stateful widgets• Asynchronous initialization & callbacks• Problem – The action1 servicing widget1 loads the current session – The action2 servicing widget2 loads the current session – action1 makes some changes to its copy of the session – action2 makes some changes to its copy of the session – action2 completes and saves its changed session data – action1 completes and saves its changed session data• action1 destroys the changes made by action2
  • ALEF stateful widgetsclass WidgetController < ApplicationController include WidgetManager before_filter :get_user_widget_id, :get_persistent after_filter :set_persistentenddef get_persistent $redis.hgetall(@widget_id).symbolize_keys.each do |key, value| if @persistent.include? key self.instance_variable_set key, Marshal.load(value) end endend
  • ALEF stateful widgetsdef set_persistent to_persist = Hash.new @persistent.each do |key| to_persist[key] = Marshal.dump(self.instance_variable_get(key)) end $redis.mapped_hmset @widget_id, to_persistend
  • ALEF background jobs• We log everything• We process logs to update user model• Solution – resque + redis – resque-poolResque.redis = Redis.new((config.symbolize_keys))Resque.enqueue(KnowledgeModellerJob, session[:user_id], @lo.id, @user_answer[:right])
  • ALEF background jobsclass KnowledgeModellerJob @queue = :knowledge_modellers def self.perform(user_id, lo_id, params) student = User.find_by_id user_id lo = LearningObject.find_by_id lo_id KnowledgeModeller.new. question_response(student, lo, params) endend