This repository was archived by the owner on Apr 20, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +3
-9
lines changed
Expand file tree Collapse file tree 2 files changed +3
-9
lines changed Original file line number Diff line number Diff line change 11#[ macro_use]
22extern crate redismodule;
33
4- use redismodule:: { Context , RedisResult , NextArg , RedisValue } ;
4+ use redismodule:: { Context , RedisResult , NextArg } ;
55use redismodule:: native_types:: RedisType ;
66
77mod redisjson;
@@ -55,7 +55,7 @@ fn json_strlen(ctx: &Context, args: Vec<String>) -> RedisResult {
5555 let key = ctx. open_key_writable ( & key) ;
5656
5757 let length = match key. get_value :: < RedisJSON > ( & REDIS_JSON_TYPE ) ? {
58- Some ( doc) => RedisValue :: Integer ( doc. str_len ( & path) ? as i64 ) ,
58+ Some ( doc) => doc. str_len ( & path) ?. into ( ) ,
5959 None => ( ) . into ( )
6060 } ;
6161
Original file line number Diff line number Diff line change @@ -62,13 +62,7 @@ impl RedisJSON {
6262
6363 pub fn str_len ( & self , path : & str ) -> Result < usize , Error > {
6464 let s = match self . get_doc ( path) ? {
65- Some ( doc) => {
66- if doc. is_string ( ) {
67- serde_json:: to_string ( & doc) ?. len ( ) - 2 // removes ""
68- } else {
69- 0 // the value is not a String
70- }
71- }
65+ Some ( doc) => doc. as_str ( ) . map_or ( 0 , |d| d. len ( ) ) ,
7266 None => 0 // path not found
7367 } ;
7468 Ok ( s)
You can’t perform that action at this time.
0 commit comments