Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lists sets hashes #3

Merged
merged 17 commits into from
Dec 7, 2014
Prev Previous commit
Next Next commit
cleanup
  • Loading branch information
dxe4 committed Nov 23, 2014
commit 253b5d7d1e3c9a1ffa4001774536f4471b0d93bf
60 changes: 30 additions & 30 deletions src/client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -271,61 +271,61 @@ function set(client::RedisClient, name::String, value; ex=nothing, px=nothing, n
end

function lindex(client::RedisClient, name::String, index::Int64)
# LINDEX key index
# Get an element from a list by its index
execute_command(client, "LINDEX", name, index)
# LINDEX key index
# Get an element from a list by its index
execute_command(client, "LINDEX", name, index)
end

function linsert(client::RedisClient, name::String, postition::String, pivot, value)
# LINSERT key BEFORE|AFTER pivot value
# Insert an element before or after another element in a list
execute_command(client, "LINSERT", name, postition, pivot, value)
# LINSERT key BEFORE|AFTER pivot value
# Insert an element before or after another element in a list
execute_command(client, "LINSERT", name, postition, pivot, value)
end

function llen(client::RedisClient, name::String)
# LLEN key
#Get the length of a list
execute_command(client, "LLEN", name)
# LLEN key
#Get the length of a list
execute_command(client, "LLEN", name)
end

function lpop(client::RedisClient, name::String)
# LPOP key
# Remove and get the first element in a list
execute_command(client, "LPOP", name)
# LPOP key
# Remove and get the first element in a list
execute_command(client, "LPOP", name)
end

function lpush(client::RedisClient, name::String, value; unpack::Bool=false)
# LPUSH key value [value ...]
# Prepend one or multiple values to a list
execute_set_command(client, "LPUSH", name, value, unpack)
# LPUSH key value [value ...]
# Prepend one or multiple values to a list
execute_set_command(client, "LPUSH", name, value, unpack)
end

function lpushx(client::RedisClient, name::String, value)
# LPUSH key value [value ...]
# Prepend one or multiple values to a list
execute_command(client, "LPUSHX", name, value)
# LPUSH key value [value ...]
# Prepend one or multiple values to a list
execute_command(client, "LPUSHX", name, value)
end

function lrange(client::RedisClient, name::String, start::Int64, stop::Int64)
# LRANGE key start stop
# Get a range of elements from a list
execute_command(client, "LRANGE", name, start, stop)
# LRANGE key start stop
# Get a range of elements from a list
execute_command(client, "LRANGE", name, start, stop)
end

function lrem(client::RedisClient, name::String, count::Int64, value)
# LREM key count value
# Remove elements from a list
execute_command(client, "LREM", name, count, value)
# LREM key count value
# Remove elements from a list
execute_command(client, "LREM", name, count, value)
end

function lset(client::RedisClient, name::String, index::Int64, value)
# LSET key index value
# Set the value of an element in a list by its index
execute_command(client, "LSET", name, index, value)
# LSET key index value
# Set the value of an element in a list by its index
execute_command(client, "LSET", name, index, value)
end

function ltrim(client::RedisClient, name::String, start::Int64, stop::Int64)
# LTRIM key start stop
# Trim a list to the specified range
execute_command(client, "LTRIM", name, start, stop)
# LTRIM key start stop
# Trim a list to the specified range
execute_command(client, "LTRIM", name, start, stop)
end
2 changes: 0 additions & 2 deletions test/test_lists.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,3 @@ client = redis()
@test ltrim(client, "spam", 3, 5) == true

@test lrange(client, "spam", 0, 10) == {"bacon", "foo", "eggs"}

@test flushall(client) == true