@@ -235,25 +235,55 @@ namespace cpp_redis {
235235 unit::int_to_string (start),unit::int_to_string (end));
236236 }
237237
238+ int incr (std::string&& key)
239+ {
240+ static_assert (is_sting_, " This API Support String Request" );
241+ if (client_ == nullptr || key.empty ()) {
242+ return -1 ;
243+ }
244+
245+ return client_->incr (std::forward<std::string>(key));
246+ }
238247
239- std::tuple<bool , int > incr (std::string&& key, int increment = 1 )
248+ // 若key不存在直接创建,并执行增加
249+ int incr_by_increment (std::string&& key, int increment)
240250 {
241251 static_assert (is_sting_, " This API Support String Request" );
242252 if (client_ == nullptr || key.empty ()) {
243- return { false ,- 1 } ;
253+ return - 1 ;
244254 }
245255
246- return client_->incr (std::forward<std::string>(key), increment);
256+ return client_->incr_by_increment (std::forward<std::string>(key),unit::int_to_string ( increment) );
247257 }
248258
249- std::tuple< bool , int > decr (std::string&& key, int increment = 1 )
259+ std::string incr_by_float (std::string&& key,float increment)
250260 {
251261 static_assert (is_sting_, " This API Support String Request" );
252- if (client_ == nullptr || key.empty ()) {
253- return { false ,-1 };
262+ if (client_ == nullptr || key.empty ()) {
263+ return " " ;
264+ }
265+
266+ return client_->incr_by_float (std::forward<std::string>(key), unit::float_to_string (increment));
267+ }
268+
269+ int decr (std::string&& key)
270+ {
271+ static_assert (is_sting_, " This API Support String Request" );
272+ if (client_ == nullptr || key.empty ()) {
273+ return -1 ;
274+ }
275+
276+ return client_->decr (std::forward<std::string>(key));
277+ }
278+
279+ virtual int decr_increment (std::string&& key,int increment)
280+ {
281+ static_assert (is_sting_, " This API Support String Request" );
282+ if (client_ == nullptr || key.empty ()) {
283+ return -1 ;
254284 }
255285
256- return client_->decr (std::forward<std::string>(key), increment);
286+ return client_->decr_increment (std::forward<std::string>(key),unit::int_to_string ( increment) );
257287 }
258288
259289 std::string get_reflect_value (std::string&& key)
@@ -325,15 +355,16 @@ namespace cpp_redis {
325355 return ptr->multi_set_if_not_set (std::forward<Args>(key_value)...);
326356 }
327357
328- std::tuple<bool , int > append_value (std::string&& key, std::string&& new_value)
358+ // key不存,会直接创建key
359+ int append_value (std::string&& key, std::string&& append_value)
329360 {
330361 static_assert (is_sting_, " This API Support String Request" );
331- if (client_ == nullptr || key.empty ()
332- || new_value.empty ) {
333- return { false ,-1 };
362+ if (client_ == nullptr || key.empty () || append_value.empty ()) {
363+ return 1 ;
334364 }
335365
336- return client_->append_value (std::forward<std::string>(key), std::forward<std::string>(new_value));
366+ return client_->append_value (std::forward<std::string>(key),
367+ std::forward<std::string>(append_value));
337368 }
338369
339370 std::tuple<bool , int > list_rpush (std::string&& key, std::string&& value)
0 commit comments