Rails: Moving from Active Record Session Store to a Redis Store


I have a large application that as many, many thousand active
sessions. I want to migrate into a Redis session store using this. And
ideally, I want my current sessions to stay active.


Does
anyone have any experience in migrating active sessions. I assume I
write either a migration or a rake task (I think migration, so I can
drop the old table as part of this), and I want to just write into
redis all the current details.


old_sessions =
ActiveRecord::Base.connection.select_all("select * from sessions") />old_sessions.each { |session| $redis.set(????? ????) } />

But I am worried about data integrity.

my rails is 3.2.8


i have gem like below

/>#gemfile
gem 'redis', '3.0.2'
gem 'redis-store',
'1.1.3'
gem 'redis-rails'
#session_store.rb />Application.config.session_store :redis_session_store />

then rails s


it report error like
below


=> Booting Thin
=> Rails 3.2.8
application starting in development on http://0.0.0.0:3000
=>
Call with -d to detach
=> Ctrl-C to shutdown server />Exiting />/Users/magicstudio/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/application/configuration.rb:140:in
`const_get'
Programming Languages

hi all I am new to redis and i want to use redis in our application
for frequent database inserts/updates and deletes.


i have
a table like this in postgres.


testtbl

unixtime | code |
flag1 |count1 | count2 | flag2 />_________________________________________________________________ />1353475056 | 1234 | A |60 | 8955 | N

1353475060 | 5248 | B |131 | 22500 | F

1353475056 | 7267 | C |36 | 10130 | X

1353475056 | 1908 | B |0 | 0 |
Programming Languages

I want to do store the parameters from a form in a model. Since I
don't want the model to use any database, it does not inherit from
ActiveRecord::Base. I'm thinking it should look something like
this:


# in view:
<% form_for :question, :url
=> {:action => "ask"} do |f| %>
<%=
f.text_field(:q) %>
<%= submit_tag %>
<% end
%>
# in controller:
def ask
# I want this to
magically set all variables in @question using
# values from
params.
@question = params[:question]
end
# in
model:
class Question
attr_accessor :q
def initia
Programming Languages

I have a large application that as many, many thousand active
sessions. I want to migrate into a Redis session store using this. And
ideally, I want my current sessions to stay active.


Does
anyone have any experience in migrating active sessions. I assume I
write either a migration or a rake task (I think migration, so I can
drop the old table as part of this), and I want to just write into
redis all the current details.


old_sessions =
ActiveRecord::Base.connection.select_all("select * from sessions") />old_sessions.each { |session| $redis.set(????? ????) } />

But I am worried about data integrity.

Programming Languages

WARNING: Complete newbie to RoR and Ruby alert! *

I have
a login method that looks like this:


@user =
Person.find(:first, :conditions => ["email=?", params[:email]]) />if @user and @user.password==params[:user_password]

session[:user] = @user
else
flash[:warn] = 'Invalid
password!'

However, the user record can get very
large, so I don't want to store the entire user record in my cookie
session.


How can I modify this code so that a specific
field does not get stored in the session? There are two fields that
can get very large (very large user profile data) an

Programming Languages

I want to store the user sessions in redis to make them usable for
Symfony2 and node.js.


Symfony2 supports MySQL and
PostgreeSQL as Session Storage but I would like to use Redis.

/>

I found this new pull request which implements already a
RedisSessionHandler: />https://github.com/Baachi/symfony/blob/redis-session-storage/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php

/>

I just didn't found anything about if it is safe to use. Has
somebody some infos or is there already some other fix (maybe a
bundle) available?

Programming Languages

- Technology - Languages
+ Webmasters
+ Development
+ Development Tools
+ Internet
+ Mobile Programming
+ Linux
+ Unix
+ Apple
+ Ubuntu
+ Mobile & Tablets
+ Databases
+ Android
+ Network & Servers
+ Operating Systems
+ Coding
+ Design Software
+ Web Development
+ Game Development
+ Access
+ Excel
+ Web Design
+ Web Hosting
+ Web Site Reviews
+ Domain Name
+ Information Security
+ Software
+ Computers
+ Electronics
+ Hardware
+ Windows
+ PHP
+ ASP/ASP.Net
+ C/C++/C#
+ VB/VB.Net
+ JAVA
+ Javascript
+ Programming
Privacy Policy - Copyrights Notice - Feedback - Report Violation 2018 © BigHow