CustomRedis
CustomRedis is based on Redis-backend library for creating easily a simple custom cache stores . It allows you to improve your application caching several kind of elements you'll use with the front-end as counters, hashes created from Active Record relations.
Installation
Add this line to your application's Gemfile:
gem 'custom_redis'
And then execute:
$ bundle
Or install it yourself as:
$ gem install custom_redis
Usage
The gem allows you to manage { key: value } elements easily autogenerating unique keys from ActiveRecord instances on a Redis server which must be running. If you have no idea how Redis works, please check Redis's homepage: First of all, after adding the gem to the Gemfile, you have to create the initializer CustomRedis.rb and add this line to start using custom_redis
CustomRedis.new
It'll create the global $custom_redis variable. It's accesible from any part of your app to use all Redis functionabilities. Otherwise CustomRedis allows you to forget several methods and manage a cache quickly.
employer = Employer.find_by_id(35)
#Returns a { key: value } element
my_custom_redis_element = CustomRedis.cr_eval(employer, :get_agreements,:build_html_resume)
#Returns a { key: value } element
my_custom_redis_selements = CustomRedis.cr_eval(employer, :get_agreements,:build_html_resume, :set)
my_custom_redis_deleted_key = CustomRedis.cr_delete(employer, :get_agreements,:build_html_resume)
my_custom_redis_flushed_keys = CustomRedis.cr_flush('employer*get_agreements*build_html_resume')
Development
After checking out the repo, run bin/setup to install dependencies. You can also run bin/console for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/lmbautista/custom_redis. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
License
The gem is available as open source under the terms of the MIT License.