Skip to content
This repository was archived by the owner on Apr 20, 2020. It is now read-only.

Commit 20be7e5

Browse files
authored
Merge pull request #2 from RedisLabsModules/rename
rename to RedisJSON
2 parents 659105b + 7037e95 commit 20be7e5

File tree

6 files changed

+22
-21
lines changed

6 files changed

+22
-21
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "redisdoc"
2+
name = "redisjson"
33
version = "0.1.0"
44
authors = ["Gavrie Philipson <gavrie@redislabs.com>"]
55
edition = "2018"

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
RedisDoc Licensing
1+
RedisJSON Licensing
22
Copyright 2018-2019 Redis Labs Ltd. and Contributors.
33

44
Licensed under the Apache License, Version 2.0 (the "License") modified with Commons Clause

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# RedisDoc
1+
# RedisJSON

src/lib.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,41 @@ extern crate redismodule;
44
use redismodule::{Context, RedisResult, NextArg};
55
use redismodule::native_types::RedisType;
66

7-
mod redisdoc;
7+
mod redisjson;
88

9-
use crate::redisdoc::RedisDoc;
9+
use crate::redisjson::RedisJSON;
1010

11-
static DOC_REDIS_TYPE: RedisType = RedisType::new("RedisDoc1");
11+
static REDIS_JSON_TYPE: RedisType = RedisType::new("RedisJSON");
12+
13+
fn json_set(ctx: &Context, args: Vec<String>) -> RedisResult {
1214

13-
fn doc_set(ctx: &Context, args: Vec<String>) -> RedisResult {
1415
let mut args = args.into_iter().skip(1);
1516

1617
let key = args.next_string()?;
17-
let value = args.next_string()?;
18+
let value = args.next_string()?;
1819

1920
let key = ctx.open_key_writable(&key);
2021

21-
match key.get_value::<RedisDoc>(&DOC_REDIS_TYPE)? {
22+
match key.get_value::<RedisJSON>(&REDIS_JSON_TYPE)? {
2223
Some(doc) => {
2324
doc.set_value(&value)?;
2425
}
2526
None => {
26-
let doc = RedisDoc::from_str(&value)?;
27-
key.set_value(&DOC_REDIS_TYPE, doc)?;
27+
let doc = RedisJSON::from_str(&value)?;
28+
key.set_value(&REDIS_JSON_TYPE, doc)?;
2829
}
2930
}
3031

3132
Ok(().into())
3233
}
3334

34-
fn doc_get(ctx: &Context, args: Vec<String>) -> RedisResult {
35+
fn json_get(ctx: &Context, args: Vec<String>) -> RedisResult {
3536
let mut args = args.into_iter().skip(1);
3637
let key = args.next_string()?;
3738

3839
let key = ctx.open_key_writable(&key);
3940

40-
let value = match key.get_value::<RedisDoc>(&DOC_REDIS_TYPE)? {
41+
let value = match key.get_value::<RedisJSON>(&REDIS_JSON_TYPE)? {
4142
Some(doc) => { doc.to_string()?.into() }
4243
None => ().into()
4344
};
@@ -48,13 +49,13 @@ fn doc_get(ctx: &Context, args: Vec<String>) -> RedisResult {
4849
//////////////////////////////////////////////////////
4950

5051
redis_module! {
51-
name: "redisdoc",
52+
name: "redisjson",
5253
version: 1,
5354
data_types: [
54-
DOC_REDIS_TYPE,
55+
REDIS_JSON_TYPE,
5556
],
5657
commands: [
57-
["doc.set", doc_set, "write"],
58-
["doc.get", doc_get, ""],
58+
["json.set", json_set, "write"],
59+
["json.get", json_get, ""],
5960
],
6061
}

src/redisdoc.rs renamed to src/redisjson.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// ReDoc Redis module.
1+
// RedisJSON Redis module.
22
//
33
// Translate between JSON and tree of Redis objects:
44
// User-provided JSON is converted to a tree. This tree is stored transparently in Redis.
@@ -23,11 +23,11 @@ impl From<Error> for redismodule::RedisError {
2323
}
2424

2525
#[derive(Debug)]
26-
pub struct RedisDoc {
26+
pub struct RedisJSON {
2727
data: Value,
2828
}
2929

30-
impl RedisDoc {
30+
impl RedisJSON {
3131
pub fn from_str(data: &str) -> Result<Self, Error> {
3232
eprintln!("Parsing JSON from input '{}'", data);
3333

0 commit comments

Comments
 (0)