Brook  Hudson

Brook Hudson

1659092839

Redis Stores: Redis Stores for Ruby Frameworks

Redis stores for Ruby frameworks

Redis Store provides a full set of stores (Cache, I18n, Session, HTTP Cache) for modern Ruby frameworks like: Ruby on Rails, Sinatra, Rack, Rack::Cache and I18n. It supports object marshalling, timeouts, single or multiple nodes, and namespaces.

Please check the README file of each gem for usage and installation guidelines.

Redis Installation

Option 1: Homebrew

MacOS X users should use Homebrew to install Redis:

brew install redis

Option 2: From Source

Download and install Redis from the download page and follow the instructions.

Running tests

git clone git://github.com/redis-store/redis-store.git
cd redis-store
bundle install
bundle exec rake

If you are on Snow Leopard you have to run env ARCHFLAGS="-arch x86_64" ruby ci/run.rb

Contributors

https://github.com/redis-store/redis-store/graphs/contributors

Versioning

The redis-store family of gems uses Semantic Versioning, meaning gems depending on redis-store can be reliably inclusive of any version between the current and the next major. We recommend the following dependency in your library's gemspec:

s.add_dependency 'redis-store', '>= 1.4', '< 2'

Status  

Copyright

2009 - 2013 Luca Guidi - http://lucaguidi.com, released under the MIT license.


Author: redis-store
Source code: https://github.com/redis-store/redis-store
License: MIT license

#ruby  #ruby-on-rails 

What is GEEK

Buddha Community

Redis Stores: Redis Stores for Ruby Frameworks
Loma  Baumbach

Loma Baumbach

1596679140

Redis Transactions & Long-Running Lua Scripts

Redis offers two mechanisms for handling transactions – MULTI/EXEC based transactions and Lua scripts evaluation. Redis Lua scripting is the recommended approach and is fairly popular in usage.

Our Redis™ customers who have Lua scripts deployed often report this error – “BUSY Redis is busy running a script. You can only call SCRIPT KILL or SHUTDOWN NOSAVE”. In this post, we will explain the Redis transactional property of scripts, what this error is about, and why we must be extra careful about it on Sentinel-managed systems that can failover.

Redis Lua Scripts Diagram - ScaleGrid Blog

Transactional Nature of Redis Lua Scripts

Redis “transactions” aren’t really transactions as understood conventionally – in case of errors, there is no rollback of writes made by the script.

Atomicity” of Redis scripts is guaranteed in the following manner:

  • Once a script begins executing, all other commands/scripts are blocked until the script completes. So, other clients either see the changes made by the script or they don’t. This is because they can only execute either before the script or after the script.
  • However, Redis doesn’t do rollbacks, so on an error within a script, any changes already made by the script will be retained and future commands/scripts will see those partial changes.
  • Since all other clients are blocked while the script executes, it is critical that the script is well-behaved and finishes in time.

The ‘lua-time-limit’ Value

It is highly recommended that the script complete within a time limit. Redis enforces this in a weak manner with the ‘lua-time-limit’ value. This is the maximum allowed time (in ms) that the script is allowed to run. The default value is 5 seconds. This is a really long time for CPU-bound activity (scripts have limited access and can’t run commands that access the disk).

However, the script is not killed when it executes beyond this time. Redis starts accepting client commands again, but responds to them with a BUSY error.

If you must kill the script at this point, there are two options available:

  • SCRIPT KILL command can be used to stop a script that hasn’t yet done any writes.
  • If the script has already performed writes to the server and must still be killed, use the SHUTDOWN NOSAVE to shutdown the server completely.

It is usually better to just wait for the script to complete its operation. The complete information on methods to kill the script execution and related behavior are available in the documentation.

#cloud #database #developer #high availability #howto #redis #scalegrid #lua-time-limit #redis diagram #redis master #redis scripts #redis sentinel #redis servers #redis transactions #sentinel-managed #server failures

Brook  Hudson

Brook Hudson

1659151800

Redis Sinatra: Redis Stores for Sinatra - Ruby

Redis stores for Sinatra

redis-sinatra provides a Redis backed cache store for Sinatra. See the main redis-store readme for general guidelines.

Installation

# Gemfile
gem 'redis-sinatra'

Usage

require 'sinatra'
require 'redis-sinatra'

class MyApp < Sinatra::Base
  register Sinatra::Cache

  get '/hi' do
    settings.cache.fetch('greet') { 'Hello, World!' }
  end
end

Keep in mind that the above fetch will return "OK" on success, not the return of the block.

Running tests

gem install bundler
git clone git://github.com/redis-store/redis-sinatra.git
cd redis-sinatra
bundle install
bundle exec rake

If you are on Snow Leopard you have to run env ARCHFLAGS="-arch x86_64" bundle exec rake

Status

Gem Version Build Status Code Climate

Copyright

2009 - 2013 Luca Guidi - http://lucaguidi.com, released under the MIT license


Author: redis-store
Source code: https://github.com/redis-store/redis-sinatra
License: MIT license

#ruby  #ruby-on-rails #ruby 

Brook  Hudson

Brook Hudson

1659144420

Redis I18n: Redis Stores for I18n - Ruby

Redis stores for I18n

redis-i18n provides a Redis backend for I18n. See the main redis-store readme for general guidelines.

Installation

# Gemfile
gem 'redis-i18n'

Usage

I18n.backend = I18n::Backend::Redis.new

Running tests

gem install bundler
git clone git://github.com/redis-store/redis-i18n.git
cd redis-i18n
bundle install
bundle exec rake

If you are on Snow Leopard you have to run env ARCHFLAGS="-arch x86_64" bundle exec rake

Status

Gem Version Build Status Code Climate

Copyright

2009 - 2013 Luca Guidi - http://lucaguidi.com, released under the MIT license


Author: redis-store
Source code: https://github.com/redis-store/redis-i18
License: MIT license

#ruby  #ruby-on-rails #redis 

Brook  Hudson

Brook Hudson

1659092839

Redis Stores: Redis Stores for Ruby Frameworks

Redis stores for Ruby frameworks

Redis Store provides a full set of stores (Cache, I18n, Session, HTTP Cache) for modern Ruby frameworks like: Ruby on Rails, Sinatra, Rack, Rack::Cache and I18n. It supports object marshalling, timeouts, single or multiple nodes, and namespaces.

Please check the README file of each gem for usage and installation guidelines.

Redis Installation

Option 1: Homebrew

MacOS X users should use Homebrew to install Redis:

brew install redis

Option 2: From Source

Download and install Redis from the download page and follow the instructions.

Running tests

git clone git://github.com/redis-store/redis-store.git
cd redis-store
bundle install
bundle exec rake

If you are on Snow Leopard you have to run env ARCHFLAGS="-arch x86_64" ruby ci/run.rb

Contributors

https://github.com/redis-store/redis-store/graphs/contributors

Versioning

The redis-store family of gems uses Semantic Versioning, meaning gems depending on redis-store can be reliably inclusive of any version between the current and the next major. We recommend the following dependency in your library's gemspec:

s.add_dependency 'redis-store', '>= 1.4', '< 2'

Status  

Copyright

2009 - 2013 Luca Guidi - http://lucaguidi.com, released under the MIT license.


Author: redis-store
Source code: https://github.com/redis-store/redis-store
License: MIT license

#ruby  #ruby-on-rails 

Brook  Hudson

Brook Hudson

1659129660

Redis ActionPack: Redis Stores for ActionPack - Ruby

Redis stores for ActionPack

redis-actionpack provides a session store for ActionPack, specifically for ActionDispatch. See the main redis-store readme for general guidelines.

For guidelines on using our underlying cache store, see the main redis-store readme.

For information on how to use this library in a Rails app, see the documentation for redis-rails.

If, for some reason, you're using ActionDispatch and not in a Rails app, read on to learn how to install/use this gem by itself!

Installation

# Gemfile
gem 'redis-actionpack'

Usage

If you are using redis-store with Rails, head on over to the redis-rails README to learn how to integrate this gem into your Rails application.

For standalone usage:

ActionController::Base.session_store = :redis_store,
  servers: %w(redis://localhost:6379/0/session),
  expire_after: 90.minutes,
  key: '_my_application_session',
  threadsafe: false,
  secure: true

A brief run-down of these options...

  • servers is an Array of Redis server URLs that we will attempt to find data from.
  • expire_after is the default TTL of session keys. This is also set as the expiry time of any cookies generated by the session store.
  • key is the name of the cookie on the client side
  • threadsafe is for applications that run on multiple instances. Set this to false if you want to disable the global mutex lock on session data. It's true by default, meaning the mutex will be enabled.
  • secure ensures HTTP cookies are transferred from server to client on a secure (HTTPS) connection

Running tests

gem install bundler
git clone git://github.com/redis-store/redis-actionpack.git
cd redis-actionpack
bundle install
bundle exec rake

If you are on Snow Leopard you have to run env ARCHFLAGS="-arch x86_64" bundle exec rake

Status

Gem Version Build Status Code Climate

Copyright

2009 - 2013 Luca Guidi - http://lucaguidi.com, released under the MIT license


Author: redis-store
Source code: https://github.com/redis-store/redis-actionpack
License: MIT license

#ruby #ruby-on-rails #redis