Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Redis commands for Elixir

License

NotificationsYou must be signed in to change notification settings

artemeff/redis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Redis commands for Elixir. If you are looking for exredis, please check outexredis branch.



Installation

Add this to the dependencies:

{:redis,"~> 0.1"}

Usage

Redis commands have a few simple types: enums, commands and primitive. Types can be required and optional, multiple and variadic, can be composite.

Situation with required and optional types is simple: required types are just arguments in function and optional values passed with the last argument —opts. opts is just a list, opts described in typespecs for each command.

Multiple arguments are arguments that contain one or more values. Multiple arguments can be optional.

Enum types in Redis is just a enumerable (usually), take a look atxx | nx enum:

iex>Redis.set("key","value",[:xx])["SET",[" ","key"],[" ","value"],[],[" ","XX"]]iex>Redis.set("key","value",[:nx])["SET",[" ","key"],[" ","value"],[],[" ","NX"]]

Commands are prefixed types, commands can wrap primitive types, enums and composite types:

# command with enum insideiex>Redis.client_kill(type::master)["CLIENT KILL",[],[],[" ",["TYPE"," ","master"]],[],[]]# command with primitive type insideiex>Redis.client_kill(id:"identity")["CLIENT KILL",[],[" ",["ID"," ","identity"]],[],[],[]]# command with composite type inside, inner type of get is: {String.t, integer()}iex>Redis.bitfield("key",get:{"type","offset"})["BITFIELD",[" ","key"],[" ",["GET"," ",["type"," ","offset"]]],[],[],[]]

You can see the usage for every Redis command in IEx:

iex>hRedis.setdefset(key,value,opts\\[])@specset(key::key(),value::String.t(),opts::[{:expiration,{:ex,:integer}|{:px,:integer}}|(:nx|:xx)|{:condition,:nx|:xx}])::iolist()since:1.0.0Set thestringvalueofakeyGroup: string.

Or head to thedocumentation on hexdocs.


Contributing

  1. Fork it
  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 new Pull Request

[8]ページ先頭

©2009-2025 Movatter.jp