Git Product home page Git Product logo

forever-alone's Introduction

ForeverAlone

forever alone

Build Status

This gem uses Redis to keep a list of recent text messages. ForeverAlone calculates hex digests of message and stores them into the Redis with a given expiration period.

Installation

Add this line to your application's Gemfile:

gem 'forever-alone'

And then execute:

$ bundle

Or install it yourself as:

$ gem install forever-alone

Usage

  # init ForeverAlone with default timeout(30 minutes)
  forever_alone = ForeverAlone.new("some message")

  # or with custom timeout
  forever_alone = ForeverAlone.new("some message", 5.minutes)

  # check if given message is unique
  forever_alone.unique?

  # remember this message
  forever_alone.remember

  # OR just ensure that message is unique and raise ForeverAlone::MessageIsNotUnique error otherwise
  forever_alone.ensure

  # if you want to flush all locks
  forever_alone.flush_locks

Configuration

Here is ForeverAlone default configuration:

ForeverAlone.configure do |config|
  config.digest     = Digest::MD5 # you can switch to Digest::SHA1
  config.timeout    = 1_800       # default expiration period
  config.namespace  = :locks      # prefix to Redis keys "locks:df49b60423903e095b80d9b4a92eb065"
end

You can configure redis connection with REDIS_URL environment variable.

Testing

You can add fakeredis to your Gemfile to prevent ForeverAlone from making requests to your Redis server.

gem "fakeredis", require: "fakeredis/rspec", group: :test

Contributing

  1. Fork it ( https://github.com/[my-github-username]/forever-alone/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

forever-alone's People

Contributors

sharshenov avatar

Stargazers

Adam Eury avatar Buts Johan avatar Preetham Hegde avatar Adis Osmonov avatar

Watchers

Sytchev Mikhail avatar Adilet Abylov avatar Adis Osmonov avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.