This repository has been archived by the owner on Jun 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Add lua and geo* support #69
Open
alecembke-okta
wants to merge
7
commits into
master
Choose a base branch
from
feature/lua
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
846f85f
lua commands
aembke 70c9b70
Merge branch 'master' of github.com:azuqua/fred.rs into feature/lua
aembke 9bbfb04
cleanup examples
aembke 08b50bf
Merge branch 'master' of github.com:azuqua/fred.rs into feature/lua
aembke 1a33664
finish lua interface, add geo command interface
aembke 3e36a21
tests, protocol parsing for nested arrays
aembke 33a9f95
fix tests for georadius
aembke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "fred" | ||
version = "1.2.2" | ||
version = "1.3.0" | ||
authors = ["Alec Embke <[email protected]>"] | ||
edition = "2018" | ||
description = "A Redis client for Rust built on Futures and Tokio." | ||
|
@@ -33,9 +33,6 @@ tokio-proto = "0.1.1" | |
tokio-io = "0.1.12" | ||
rand = "0.3" | ||
|
||
[dev-dependencies] | ||
hyper = "0.11" | ||
|
||
[lib] | ||
doc = true | ||
doctest = false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -209,6 +209,32 @@ pub trait RedisClientBorrowed { | |
|
||
fn pttl<K: Into<RedisKey>>(&self, key: K) -> Box<Future<Item=i64, Error=RedisError>>; | ||
|
||
fn script_load<S: Into<String>>(&self, script: S) -> Box<Future<Item=String, Error=RedisError>>; | ||
|
||
fn script_flush(&self) -> Box<Future<Item=(), Error=RedisError>>; | ||
|
||
fn script_exists<S: Into<MultipleKeys>>(&self, sha1: S) -> Box<Future<Item=Vec<bool>, Error=RedisError>>; | ||
|
||
fn evalsha<S: Into<String>, K: Into<MultipleKeys>, V: Into<MultipleValues>>(&self, sha1: S, keys: K, args: V) -> Box<Future<Item=Vec<RedisValue>, Error=RedisError>>; | ||
|
||
fn geoadd<K: Into<RedisKey>, V: Into<MultipleGeoValues>>(&self, key: K, values: V) -> Box<Future<Item=usize, Error=RedisError>>; | ||
|
||
fn geohash<K: Into<RedisKey>, V: Into<MultipleValues>>(&self, key: K, values: V) -> Box<Future<Item=Vec<String>, Error=RedisError>>; | ||
|
||
fn geopos<K: Into<RedisKey>, V: Into<MultipleValues>>(&self, key: K, values: V) -> Box<Future<Item=Vec<Option<(Longitude, Latitude)>>, Error=RedisError>>; | ||
|
||
fn geodist<K: Into<RedisKey>, M: Into<RedisValue>, N: Into<RedisValue>>(&self, key: K, member1: M, member2: N, unit: Option<GeoUnit>) -> Box<Future<Item=Option<f64>, Error=RedisError>>; | ||
|
||
fn georadius<K: Into<RedisKey>>(&self, key: K, longitude: Longitude, latitude: Latitude, radius: f64, unit: GeoUnit, | ||
withcoord: bool, withdist: bool, withhash: bool, count: Option<usize>, | ||
order: Option<GeoOrdering>, store: Option<String>, storedist: Option<String>) | ||
-> Box<Future<Item=Vec<RedisValue>, Error=RedisError>>; | ||
|
||
fn georadiusbymember<K: Into<RedisKey>, V: Into<RedisValue>>(&self, key: K, member: V, radius: f64, unit: GeoUnit, | ||
withcoord: bool, withdist: bool, withhash: bool, count: Option<usize>, | ||
order: Option<GeoOrdering>, store: Option<String>, storedist: Option<String>) | ||
-> Box<Future<Item=Vec<RedisValue>, Error=RedisError>>; | ||
|
||
} | ||
|
||
|
||
|
@@ -825,6 +851,88 @@ impl RedisClientBorrowed for RedisClient { | |
commands::pttl(&self.inner, key) | ||
} | ||
|
||
/// Load a script into the scripts cache, without executing it. | ||
/// | ||
/// <https://redis.io/commands/script-load> | ||
fn script_load<S: Into<String>>(&self, script: S) -> Box<Future<Item=String, Error=RedisError>> { | ||
commands::script_load(&self.inner, script) | ||
} | ||
|
||
/// Flush the Lua scripts cache. | ||
/// | ||
/// <https://redis.io/commands/script-flush> | ||
fn script_flush(&self) -> Box<Future<Item=(), Error=RedisError>> { | ||
commands::script_flush(&self.inner) | ||
} | ||
|
||
/// Returns information about the existence of the scripts in the script cache. | ||
/// | ||
/// This command accepts one or more SHA1 digests and returns a list of ones or zeros to signal if the scripts are already defined or not inside the script cache. | ||
/// | ||
/// <https://redis.io/commands/script-exists> | ||
fn script_exists<S: Into<MultipleKeys>>(&self, sha1: S) -> Box<Future<Item=Vec<bool>, Error=RedisError>> { | ||
commands::script_exists(&self.inner, sha1) | ||
} | ||
|
||
/// Evaluates a script cached on the server side by its SHA1 digest. | ||
/// | ||
/// Scripts are cached on the server side using the SCRIPT LOAD command. | ||
/// | ||
/// <https://redis.io/commands/evalsha> | ||
fn evalsha<S: Into<String>, K: Into<MultipleKeys>, V: Into<MultipleValues>>(&self, sha1: S, keys: K, args: V) -> Box<Future<Item=Vec<RedisValue>, Error=RedisError>> { | ||
commands::evalsha(&self.inner, sha1, keys, args) | ||
} | ||
|
||
/// Adds the specified geospatial items (latitude, longitude, name) to the specified key. | ||
/// | ||
/// <https://redis.io/commands/geoadd> | ||
fn geoadd<K: Into<RedisKey>, V: Into<MultipleGeoValues>>(&self, key: K, values: V) -> Box<Future<Item=usize, Error=RedisError>> { | ||
commands::geoadd(&self.inner, key, values) | ||
} | ||
|
||
/// Return valid Geohash strings representing the position of one or more elements in a sorted set value representing a geospatial index. | ||
/// | ||
/// <https://redis.io/commands/geohash> | ||
fn geohash<K: Into<RedisKey>, V: Into<MultipleValues>>(&self, key: K, values: V) -> Box<Future<Item=Vec<String>, Error=RedisError>> { | ||
commands::geohash(&self.inner, key, values) | ||
} | ||
|
||
/// Return the positions (longitude,latitude) of all the specified members of the geospatial index represented by the sorted set at key. | ||
/// | ||
/// <https://redis.io/commands/geopos> | ||
fn geopos<K: Into<RedisKey>, V: Into<MultipleValues>>(&self, key: K, values: V) -> Box<Future<Item=Vec<Option<(Longitude, Latitude)>>, Error=RedisError>> { | ||
commands::geopos(&self.inner, key, values) | ||
} | ||
|
||
/// Return the distance between two members in the geospatial index represented by the sorted set. | ||
/// | ||
/// <https://redis.io/commands/geodist> | ||
fn geodist<K: Into<RedisKey>, M: Into<RedisValue>, N: Into<RedisValue>>(&self, key: K, member1: M, member2: N, unit: Option<GeoUnit>) -> Box<Future<Item=Option<f64>, Error=RedisError>> { | ||
commands::geodist(&self.inner, key, member1, member2, unit) | ||
} | ||
|
||
/// Return the members of a sorted set populated with geospatial information using GEOADD, which are within the borders of the area specified with the center location and the maximum distance from the center (the radius). | ||
/// | ||
/// <https://redis.io/commands/georadius> | ||
fn georadius<K: Into<RedisKey>>(&self, key: K, longitude: Longitude, latitude: Latitude, radius: f64, unit: GeoUnit, | ||
withcoord: bool, withdist: bool, withhash: bool, count: Option<usize>, | ||
order: Option<GeoOrdering>, store: Option<String>, storedist: Option<String>) | ||
-> Box<Future<Item=Vec<RedisValue>, Error=RedisError>> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you use rustfmt? It's brilliant tool. |
||
{ | ||
commands::georadius(&self.inner, key, longitude, latitude, radius, unit, withcoord, withdist, withhash, count, order, store, storedist) | ||
} | ||
|
||
/// This command is exactly like GEORADIUS with the sole difference that instead of taking, as the center of the area to query, a longitude and latitude value, it takes the name of a member already existing inside the geospatial index represented by the sorted set. | ||
/// | ||
/// <https://redis.io/commands/georadiusbymember> | ||
fn georadiusbymember<K: Into<RedisKey>, V: Into<RedisValue>>(&self, key: K, member: V, radius: f64, unit: GeoUnit, | ||
withcoord: bool, withdist: bool, withhash: bool, count: Option<usize>, | ||
order: Option<GeoOrdering>, store: Option<String>, storedist: Option<String>) | ||
-> Box<Future<Item=Vec<RedisValue>, Error=RedisError>> | ||
{ | ||
commands::georadiusbymember(&self.inner, key, member, radius, unit, withcoord, withdist, withhash, count, order, store, storedist) | ||
} | ||
|
||
} | ||
|
||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be more readable with where clause.