Coder Social home page Coder Social logo

eredis's Introduction

eredis - An Emacs client API for Redis

Introduction

eredis is a redis client written in Emacs Lisp

Melpa Status

  • MELPA

Features

  • Almost everything implemented
  • Redis 5.0 support including LOLWUT
  • Multiple connections to multiple Redis servers
  • Integration with org-mode
  • Handles multibyte characters correctly
  • Buffer per connection shows all Redis output

Currently this package does not support Windows Redis servers due to differences in newline handling. This is an open issue and pull requests are welcome. I do not soil my hands with Windows machines, if I can avoid it.

Installation

From source

Download the latest version via svn or from the downloads page. Add the path you downloaded it to in your .emacs file:

(add-to-list 'load-path "~/eredis/")

(require 'eredis)

You can find a test suite in the tests folder that uses ert.

From Melpa

Melpa

M-x package-install eredis

Usage

First connect to the server. Some of the commands are interactive but all work from the emacs lisp REPL. To get that:

M-x ielm

A redis session begins by connecting to a server. It returns a process which you can use for further operations.

(setq p1 (eredis-connect "localhost" 6379))

and ends by closing the connection:

(eredis-disconnect p1)

Most commands receive a string response from Redis such as eredis-ping, which returns "PONG". Some return lists of strings, and others return maps of key value pairs. I've tried to follow the principle of least surprise when implementing each call.

Some examples of basic usage:

(eredis-set "key" "value") "ok"

(eredis-get "key") "value"

(eredis-info)

Returns a hash table of the key values that represent the Redis info response.

Monitor Mode

All commands work as you would expect, except for monitor. Monitor starts to show all the commands going to the Redis server, and as such does not fit with a single asynchronous API call. What I do instead is to switch you to the redis buffer where you can watch the commands. Hit C-g to exit this mode. You will need to reconnect to the Redis server once you are done, because the QUIT command that exits the client from monitor mode seems to close the connection too.

(eredis-monitor)

Org table mode

You can pull a range of values from the Redis server and create an org table, which can be further manipulated, values changed and so on...

(eredis-org-table-from-set "s1")

(eredis-org-table-from-zset "z1")

(eredis-org-table-from-zset "z1" 'withscores)

(eredis-org-table-from-hash "testhash1")

(eredis-org-table-from-list "l1")

(eredis-org-table-from-pattern "configparam..server1")

(defun eredis-org-table-mset()

"with point in an org table convert the table to a map and send it to redis with mset"

(defun eredis-org-table-msetnx()

"with point in an org table convert the table to a map and send it to redis with msetnx"

(defun eredis-org-table-row-set()

"with point in an org table set the key and value"

More to come

More caveats

Almost the entire Redis API works no problem, except for the publish subscribe commands, which I have a little more work to do on. Same goes for MULTI and EXEC. These commands work, but the output of the final EXEC is not correctly parsed yet.

License etc

See the source code in eredis.el for licensing information, contributor thanks etc

eredis's People

Contributors

crispywalrus avatar justinhj avatar lctt9972 avatar lujun9972 avatar pidu avatar walseb avatar

Watchers

 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.