Skip to content

Instantly share code, notes, and snippets.

@mkhuda
Created June 3, 2017 01:33
Show Gist options
  • Save mkhuda/b1a71ed756321461bc74a5e04db2c1fe to your computer and use it in GitHub Desktop.
Save mkhuda/b1a71ed756321461bc74a5e04db2c1fe to your computer and use it in GitHub Desktop.
Redis MULTI and HSET on Rails
module RedisProjectHelper
# set hash
def set_project!(sample_store_id, sample_store_name)
$redis.multi do
$redis.hset(self.redis_new_project_key(), 'sample_id', sample_store_id)
$redis.hset(self.redis_new_project_key(), 'sample_name', sample_store_name)
end
end
# set redis key
def redis_new_project_key()
"new_project:#{current_user.id}:data"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment