Skip to content
This repository has been archived by the owner on Jul 6, 2024. It is now read-only.

Commit

Permalink
Renaming command prefix from is to iset and command is.set to iset.add (
Browse files Browse the repository at this point in the history
  • Loading branch information
danitseitlin committed Feb 28, 2021
1 parent 4d19738 commit 4adc87b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
44 changes: 22 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ Interval sets are similar to ZSET command of Redis, but unlike ZSET's it's a ran
For example let's say we have a key called ages, that holds free sets of age ranges, pre school, highschool, and college.
We will set it as following:
```
redis> is.set ages preschool 6 11
redis> is.set ages highschool 11 18 college 18 50
redis> iset.add ages preschool 6 11
redis> iset.add ages highschool 11 18 college 18 50
```
We will result in a key with 3 sets of age ranges.
Now we want to filter out specific set that hold a number in their range, for i.e. `is.score ages 11`
Now we want to filter out specific set that hold a number in their range, for i.e. `iset.score ages 11`
Filtering for the value 11, will results in returning 2 available sets: preschool and highschool.

## Primary features
Expand All @@ -22,65 +22,65 @@ docker run -p 6379:6379 --name ris danitseitlin/redis-interval-sets:latest

## Commands

### is.set
### iset.add
This command sets a new interval set. An interval set can be extended at any time.
In the command itself we are able to create 1 or more sets at the same command execution.
Each set **MUST** have a minimum score and a maximum score
```
is.set <key> <set name> <min-score> <max-score> [<set name> <min-score> <max-score>...]
redis> is.set ages highschool 12 18
iset.add <key> <set name> <min-score> <max-score> [<set name> <min-score> <max-score>...]
redis> iset.add ages highschool 12 18
```

### is.get
### iset.get
```
This command returns existing sets and their min & max scores.
If set name is used, it will retrieve the min & max scores of a specific set.
is.get <key> [set name]
redis> is.get ages
iset.get <key> [set name]
redis> iset.get ages
1) 1) "a"
2) "1"
3) "5"
2) 1) "b"
2) "3"
3) "65"
redis> is.get ages preschool
redis> iset.get ages preschool
1) 1) "6"
2) "11"
```

### is.score
### iset.score
```
This command searches for existing sets that have the given score in their score range.
The returned information is the name of the set **ONLY**
is.score <key> <score>
redis> is.score ages 1
iset.score <key> <score>
redis> iset.score ages 1
1) "a"
redis> is.score ages 5
redis> iset.score ages 5
1) "a"
2) "b"
```

### is.not_score
### iset.not_score
```
This command searches for existing sets that don't have the given score in their score range.
The returned information is the name of the set **ONLY**
is.not_score <key> <score>
redis> is.not_score ages 1
iset.not_score <key> <score>
redis> iset.not_score ages 1
1) "b"
redis> is.not_score ages 5
redis> iset.not_score ages 5
(empty list or set)
```

### is.del
### iset.del
```
This command can delete a key or a specific set. If no <set name> is passed, the whole list of sets (the key itself) will be removed.
To remove a sepecific set, we will pass **at least** one set name.
is.del <key> [<set name>...]
redis> is.del ages highschool
iset.del <key> [<set name>...]
redis> iset.del ages highschool
OK
redis> is.del ages
redis> iset.del ages
OK
```

Expand Down
12 changes: 6 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ fn is_get(ctx: &Context, args: Vec<String>) -> RedisResult {

let key = ctx.open_key(&key);

println!("is.get on key");
println!("iset.get on key");

match key.get_value::<IntervalSet>(&REDIS_INTERVAL_SETS)? {
Some(value) => {
Expand Down Expand Up @@ -216,11 +216,11 @@ redis_module! {
REDIS_INTERVAL_SETS
],
commands: [
["is.set", is_set, "write", 1, 1, 1],
["is.del", is_del, "write", 1, 1, 1],
["is.get", is_get, "readonly", 1, 1, 1],
["is.score", is_score, "readonly", 1, 1, 1],
["is.not_score", is_not_score, "readonly", 1, 1, 1],
["iset.add", is_set, "write", 1, 1, 1],
["iset.del", is_del, "write", 1, 1, 1],
["iset.get", is_get, "readonly", 1, 1, 1],
["iset.score", is_score, "readonly", 1, 1, 1],
["iset.not_score", is_not_score, "readonly", 1, 1, 1],
],
}

Expand Down

0 comments on commit 4adc87b

Please sign in to comment.