Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ serde_json = "1.0"
serde = "1.0"
libc = "0.2"
jsonpath_lib = { git="https://github.com/RedisJSON/jsonpath.git", branch="public-parser" }
redis-module = { version="0.16", features = ["experimental-api"]}
lazy_static = "1.4.0"
redis-module = { version="0.17", features = ["experimental-api"]}
# readies-wd40 = { path = "deps/readies/wd40" }

[features]
Expand Down
12 changes: 11 additions & 1 deletion src/c_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use crate::redisjson::Format;
use crate::{redisjson::RedisJSON, REDIS_JSON_TYPE};
use redis_module::key::RedisKeyWritable;
use redis_module::logging::log_notice;
use redis_module::{key::verify_type, Context, Status};
use redis_module::{raw as rawmod, RedisError};
use redis_module::{Context, Status};
use serde_json::Value;

// extern crate readies_wd40;
Expand Down Expand Up @@ -242,6 +242,14 @@ pub extern "C" fn JSONAPI_getRedisModuleStringFromKey(
}
}

#[no_mangle]
pub extern "C" fn JSONAPI_isJSON(key: *mut rawmod::RedisModuleKey) -> c_int {
match verify_type(key, &REDIS_JSON_TYPE) {
Ok(_) => 1,
Err(_) => 0,
}
}

fn get_int_value(value: &Value) -> Option<c_long> {
match value {
Value::Number(ref n) => {
Expand Down Expand Up @@ -523,6 +531,7 @@ static JSONAPI: RedisJSONAPI_V1 = RedisJSONAPI_V1 {
getStringFromKey: JSONAPI_getStringFromKey,
getRedisModuleString: JSONAPI_getRedisModuleString,
getRedisModuleStringFromKey: JSONAPI_getRedisModuleStringFromKey,
isJSON: JSONAPI_isJSON,
};

#[repr(C)]
Expand Down Expand Up @@ -577,4 +586,5 @@ pub struct RedisJSONAPI_V1<'a> {
path: *const c_char,
str: *mut *mut rawmod::RedisModuleString,
) -> c_int,
pub isJSON: extern "C" fn(key: *mut rawmod::RedisModuleKey) -> c_int,
}
4 changes: 4 additions & 0 deletions src/include/rejson_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ typedef struct RedisJSONAPI_V1 {
// Caller gains ownership of `str`
int (*getRedisModuleString)(RedisJSON json, RedisModuleString **str);
int (*getRedisModuleStringFromKey)(RedisJSONKey key, const char *path, RedisModuleString **str);

// Return 1 if type of key is JSON
int (*isJSON)(RedisModuleKey *redis_key);

} RedisJSONAPI_V1;

#ifdef __cplusplus
Expand Down