Sidekiq : Redis : Namespace

You need to add the gem ‘redis-namespace’ to namespace the redis keys via sidekiq

From the command line:

$ gem install redis-namespace

Or in your Gemfile:

gem 'redis-namespace'

When you might need this?

If you have multiple server environment or multiple applications hosted using the same redis server then you must namespace your data. Otherwise sidekiq will try to execute tasks from one application with another application’s codebase.

Continue reading

Advertisements

Rails : Sidekiq 4.0 : no :symbol keys supported when hash is passed as argument

 

NotificationAsync.perform_later({data:{pact_id: 1}, context: OrdersSignup::Notification::WelcomeChild.to_s})

I was sending Hash as a parameter/argument to my worker but it was now able to access the keys/values using :symbol as a key name

So Explicitly use ActiveSupport’s `.with_indifferent_access`
Continue reading

Ruby On Rails : Redis Server : Sidekiq : How to Install Redis in Ubuntu 14.04

What is Redis?

Redis is an open source, BSD licensed, advanced key-value cache and store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets,sorted sets, bitmaps and hyperloglogs.

How to install?

Download the latest and stable tar file from the following link or from anywhere you like

$ wget http://download.redis.io/releases/redis-2.8.9.tar.gz

Untar (like Unzip)  it and switch into that directory:

$ tar xzf redis-2.8.9.tar.gz
# Or simply right click on the file and click 'Extract'
$ cd redis-2.8.9

Proceed to with the make command:

$ make

Run the recommended make test:

$ make test

Finish up by running make install, which installs the program system-wide.

$ sudo make install

Once the program has been installed, Redis comes with a built in script that sets up Redis to run as a background daemon.

To access the script move into the utils directory:

$ cd utils

From there, run the Ubuntu/Debian install script:

$ sudo ./install_server.sh

It will ask the following

Welcome to the redis service installer
This script will help you easily set up a running redis server
> Please select the redis port for this instance: [6379]
# You can enter the port you like, 6379 is default : Suggested to change
# Or you can just press ENTER, it will use default PORT
Selecting default: 6379
> Please select the redis config file name [/etc/redis/6379.conf] 
# You can just press ENTER, it will use default PORT
Selected default - /etc/redis/6379.conf
> Please select the redis log file name [/var/log/redis_6379.log] 
# You can just press ENTER, it will use default PORT

Run Redis-Server

$ redis-server
Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf

Note: Creating Server TCP listening socket *:6379: bind: Address already in use then
$ redis-cli ping
> pong
# If it returns 'pong' then an instance already exists
$ redis-cli
127.0.0.1:6379> shutdown
not connected> exit
# exit command exits the cli
# you can again try
$ redis-server

References:

https://www.digitalocean.com/community/tutorials/how-to-install-and-use-redis

http://redis.io/