12
RespClient Minimal Redis Client for PowerShell 2014/07/12 Yoshifumi Kawai - @neuecc

RespClient - Minimal Redis Client for PowerShell

Embed Size (px)

DESCRIPTION

RespClient is a minimal RESP(REdis Serialization Protocol) client for C# and PowerShell. https://github.com/neuecc/RespClient at Japan PowerShell User Group #3 #jpposh

Citation preview

Page 1: RespClient - Minimal Redis Client for PowerShell

RespClientMinimal Redis Client for PowerShell

2014/07/12Yoshifumi Kawai - @neuecc

Page 2: RespClient - Minimal Redis Client for PowerShell

Self Introduction

@仕事

株式会社グラニ取締役CTO

C# 5.0 + .NET Framework 4.5 + ASP.NET MVC 5

最先端C#によるハイパフォーマンスWebアプリケーション

@個人活動

Microsoft MVP for Visual C#

Web http://neue.cc/

Twitter @neuecc

linq.js - http://linqjs.codeplex.com/とか作ってます

Page 3: RespClient - Minimal Redis Client for PowerShell

Redis/RESPREmote DIctionary Server/REdis Serialization Protocol

Page 4: RespClient - Minimal Redis Client for PowerShell

About Redis

インメモリKey-Valueストア

KVS系では現在、最も人気が高い

単純なKey-Valueの他にListやSetなど多様なデータ型が使える

リモート上のデータ構造という、いい具合のサイズ感が魅力

Windowsでも動く

MicrosoftがforkしたWindowsバイナリあり

AWSやAzureがManagedなCacheServerとして正式提供

それを受けてMicrosoftがASP.NET用のSessionProviderを公開したり

Windowsでも、間違いなく標準的なKVSとなっていくだろう

Page 5: RespClient - Minimal Redis Client for PowerShell

About RESP

Redis SErialization Protocol

http://redis.io/topics/protocol

Redisのプロトコル、どういうバイナリ送れば実行されるか

Simple to implement.

Fast to parse.

Human readable.

かなりシンプル

public enum RespType : byte{

SimpleStrings = (byte)'+',Erorrs = (byte)'-',Integers = (byte)':',BulkStrings = (byte)'$',Arrays = (byte)'*'

}C#で先頭識別子の定義するとこんな感じになる、簡単そう?

Page 6: RespClient - Minimal Redis Client for PowerShell

RespClientminimal RESP(REdis Serialization Protocol) client for PowerShell

Page 7: RespClient - Minimal Redis Client for PowerShell

RespClient

シンプルなPowerShell用Redisライブラリ

https://github.com/neuecc/RespClient

現在はNuGetで配ってます。が、PowerShellGet?よくわからな

いけれどぎたぱそ先生がなんかいい具合に配ってくれるでしょ

ういつかきっとおそらく

非依存・コマンドレット提供

自前でプロトコル解釈してるので外部ライブラリ不要

コマンドレットを完備してる唯一の.NET用Redisライブラリ

Page 8: RespClient - Minimal Redis Client for PowerShell

Why RespClient?

.NET用Redisクライアントは幾つかある

特にRedis/C#についてはBuildInsiderに書いたので読んでね

http://www.buildinsider.net/small/rediscshap/01

が、.NET用は基本C#用でPowerShell用ではない

使い心地がヘヴィで、PowerShellで使いやすくない

redis-cli的な、PowerShellネイティブなクライアントが欲しい

というわけで、自分で作った(但し実装は(当然)C#)

PowerShellからWindowsのRedisもLinuxのRedisも管理できる

Page 9: RespClient - Minimal Redis Client for PowerShell

Demo...Connect/Send-Command with RespClient

Page 10: RespClient - Minimal Redis Client for PowerShell

How to use : Commandlet

# モジュールはdllで提供されているので読み込むImport-Module RespClient.dll

# RedisServerへの接続。# ConnectionはPowerShellのセッションが有効な間繋がりっぱなしになる。# 他にオプションとして-Host, -Port, -TimeoutConnect-RedisServer 127.0.0.1

# 繋がったコネクションでコマンドを送るSend-RedisCommand "set test 100"Send-RedisCommand "get test"Send-RedisCommand "incr test"

# PowerShellなのでパイプラインで送れるのが強み!@(1,2,3) | % { Send-RedisCommand "incrby test $_" }

# 明示的に切る場合はDisconnectコマンドをDisconnect-RedisServer

Page 11: RespClient - Minimal Redis Client for PowerShell

Conclusion

Page 12: RespClient - Minimal Redis Client for PowerShell

まとめ

Redis is very very important!

これからのWeb開発でRedis知らないのはありえない

Windowsにおいてもそれは変わらない

管理するならば?

やはりPowerShellで行いたい!RespClient!

http://neue.cc/2014/03/11_447.html ←紹介記事

もちろんWindowsで動くRedisだけじゃなく、Linuxで動くRedis

にも繋がってPowerShellで自由に操作可能です