Project Description

 
This project provides a way to access a Redis server via Powershell Cmdlets. You can use command like Get-RedisKey, Add-RedisSetItems, and Remove-RedisHashEntry to manipulate the keys on the redis server.

 

Requirements

  1. Free Redis Server = http://redis.io/
  2. Powershell
  3. .Net 4.0

How to get started

  1. Download the Zip file and extract it to one of the module directories for powershell
    C:\Windows\System32\WindowsPowerShell\v1.0\Modules

  2. To make Powershell support .Net 4.0 create or edit your PowerShell.exe.Config in C:\Windows\System32\WindowsPowerShell\v1.0 to look like this 
    <?xml version="1.0"?> 
    <configuration>
    <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0.30319"/>
    <supportedRuntime version="v2.0.50727"/>
    </startup>
    </configuration>

  3. Import the module using Import-Module PowerRedis
    get-module –list PowerRedis | import-module

  4. Make sure your redis server is up and running.
  5. Use Connect-RedisServer –RedisServer “dns name or IP of your server”. i.e.
    Connect-RedisServer -RedisServer "192.168.1.2"

  6. Type “Search-RedisKeys *” to get a list of your redis keys. FYI this could take a while if you have a lot of keys…

Useful Links

  1. C# Service Stack library this project wraps.https://github.com/ServiceStack/ServiceStack.Redis
  2. Redis Server.http://redis.io/

 

Cmdlet Mapping

Keys  
KEYS Search-RedisKeys
DEL Remove-RedisKey
EXISTS Get-RedisExists
EXPIRE Set-RedisExpire
EXPIREAT Set-RedisExpiresAt
RANDOMKEY Get-RedisRandomKey
RENAME Rename-RedisKey
TTL Get-RedisTTL
Type Get-RedisType
--Not implemented  
Move,object,persist,renamenx,sort,eval  
   
Strings  
GET Get-RedisKey
SET Set-RedisKey
--Not implemented  
append,decr,decrby,getbit,getrange,getset  
incr,mget,mset,msetnx,setbit,setex,setnx,setrange  
   
Hashes  
HSET Set-RedisHashValue
HSETNX Set-RedisHashValueIfNotExists
HMGET Get-RedisHashAll
HGET Get-RedisHashValue
HGETVALUES Get-RedisHashValues
HKKEYS Get-RedisHashKeys
HDEL Remove-RedisHashEntry
HEXISTS Get-RedisHashExists
HINCRBY Set-RedisHashIncrement
HLEN Get-RedisHashLength
HMSET Set-RedisHashValues
   
Lists  
  Get-RedisList
  Add-RedisListItems
RPush Add-RedisListItem
LRange Get-RedisListRange
BLPOP Get-RedisLBPOP
BRPOPLPUSH Set-RedisBRPopLPush
LINDEX Get-RedisListIndex
LLEN Get-RedisListLength
LPOP Remove-RedisListLPop
RPOP Remove-RedisListRPop
LREM Remove-RedisListElements
LTRIM Set-RedisListTrim
--Not Implemented  

linsert, lset, lpush, rpoplpush, rpushx, lpushx

 
   
Sets  
SMEMBERS Get-RedisSet
SADDS Add-RedisSetItems
SADD Add-RedisSetItem
SCARD Get-RedisSetCount
SDIFF Set-RedisSetDiff
SDIFFSTORE Set-RedisSetDiffStore
SINTER Set-RedisSetIntersect
SINTERSECTSTORE Set-RedisSetIntersectStore
SISMEMBER Get-RedisSetIsMember
SMOVE Get-RedisSetMove
SPOP Set-RedisSetPop
SMOVE Get-RedisSetRandom
SREM Remove-RedisSetMember
SUNION Add-RedisSets
SUNIONSTORE Add-RedisSetsStore
   
SortedSets  
ZADDSCORE Add-RedisSortedSetItemScore
ZADD Add-RedisSortedSetItem
ZCARD Get-RedisSortedSetCount
-- Not Implemented  
zcount,zincrby,zinterstore,zrange,zrangebyscore,zrank
zrem,zremrangebyrank,zremrangebyscore,zrevrange
zrevrank,zscore,zunionstore
 
   
Strings  
GET Get-RedisKey
SET Set-RedisKey
   
Server  
INFO Get-RedisInfo
   
Others not implemented  
Pub/Sub and Transactions  

Last edited Jul 5, 2012 at 11:47 PM by JohnFiedler, version 28