🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

redislike

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redislike

bundlerRubyGems.org
Version
0.2.12
Version published
Maintainers
1
Created
Source

#+TITLE: redislike - redis-like list operations for moneta #+LATEX: \pagebreak

  • Overview

    redislike adds backend-independent support for redis-like list operations to any Moneta datastore.

  • Supported Operations

    • BLPOP
    • BRPOP
    • BRPOPLPUSH
    • LINDEX
    • LINSERT
    • LLEN
    • LPOP
    • LPUSH
    • LPUSHX
    • LRANGE
    • LREM
    • LSET
    • LTRIM
    • RPOP
    • RPOPLPUSH
    • RPUSH
    • RPUSHX
  • Other Supported Operations

    • EXISTS
  • Differences from Redis

    • LSET with a non-existent list raises a =KeyError= rather than a =Redis::CommandError=.
    • LSET with an out of range index raises an =IndexError= rather than a =Redis::CommandError=.
  • Installation

    #+BEGIN_SRC shell gem install redislike #+END_SRC

  • Example

    #+BEGIN_SRC ruby require 'redislike' datastore = Moneta.new :Memory, expires: true

    datastore.lpush 'pending', 'foo' datastore.rpoplpush 'pending', 'active' puts datastore.lrange 'active', 0, -1 #+END_SRC

    Returns =['foo']=

  • Motivation

    Redis may be my favourite data store, for a number of reasons that have nothing to do with this gem. It's also not a silver bullet. Like many tools, used in the right context, it excels. Out of its element, it adds complexity and overhead (when compared to using a tool better suited to that problem domain).

    Then there's Moneta, a lovely gem that provides a unified API to an impressive range of backends for key/value storage. This allows low-effort integration with whatever data store you already have. The consistency also enables trivial swapping of backends as the evolution of an application guides requirements, without rewriting much of anything.

    To achive this consistency, Moneta omits support for backend-specfic features. One of those that I often want is the (B)RPOPLPUSH list operation from Redis. This takes an item from the tail of one list, and puts it at the head of another list.

    Rather than depending on a Redis backend for Moneta, and passing these operations through to it, I built redis-like queue operations on top of Moneta. Once those were in place, it seemed reasonable to continue and build the rest.

    At this point, some sort of scope began to take shape. The methods were restructured to align with those provided by Redis, and tests were written to guide this process.

    TL;DR: I wanted RPOPLPUSH in Moneta, didn't define scope boundaries and accidentally reimplemented (some of) Redis.

  • What's up with the tests?

    Alright, so the tests are a bit unconventional, in the sense that you need a working redis server to actually run the tests for a gem with the stated intent of not requiring a redis server.

    These tests that redislike is in fact, redis-like. These work by executing the same instructions against redis, and an in-memory instance of redislike, and asserting that the results should be the same.

  • License

    redislike is available under the [[https://tldrlegal.com/license/mit-license][MIT License]]. See LICENSE.txt for the full text.

  • Contributors

FAQs

Package last updated on 16 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts