1
0
Fork 0
mirror of https://github.com/KingDuckZ/incredis synced 2024-11-23 00:33:46 +00:00

Replace string_ref with string_view.

This commit is contained in:
King_DuckZ 2017-06-06 21:06:22 +01:00
parent 2c324ae647
commit ff802e975a
17 changed files with 103 additions and 104 deletions

View file

@ -20,7 +20,7 @@
#include "duckhandy/compatibility.h"
#include <cstddef>
#include <boost/utility/string_ref.hpp>
#include <boost/utility/string_view.hpp>
#include <string>
namespace redis {
@ -45,8 +45,8 @@ namespace redis {
};
template<>
struct MakeCharInfo<boost::string_ref> {
MakeCharInfo ( const boost::string_ref& parData ) : m_data(parData.data()), m_size(parData.size()) {}
struct MakeCharInfo<boost::string_view> {
MakeCharInfo ( const boost::string_view& parData ) : m_data(parData.data()), m_size(parData.size()) {}
const char* data ( void ) const { return m_data; }
std::size_t size ( void ) const { return m_size; }
@ -73,7 +73,7 @@ namespace redis {
std::size_t size ( void ) const { return m_data.size(); }
private:
boost::string_ref m_data;
boost::string_view m_data;
};
template <typename T>

View file

@ -75,12 +75,12 @@ namespace redis {
using implem::arg_to_bin_safe_char;
using implem::arg_to_bin_safe_length;
using implem::MakeCharInfo;
using boost::string_ref;
using boost::string_view;
this->run_pvt(
static_cast<int>(arg_count),
CharPointerArray{ (arg_to_bin_safe_char(string_ref(parCommand))), MakeCharInfo<typename std::remove_const<typename std::remove_reference<Args>::type>::type>(std::forward<Args>(parArgs)).data()... }.data(),
LengthArray{ arg_to_bin_safe_length(string_ref(parCommand)), arg_to_bin_safe_length(std::forward<Args>(parArgs))... }.data()
CharPointerArray{ (arg_to_bin_safe_char(string_view(parCommand))), MakeCharInfo<typename std::remove_const<typename std::remove_reference<Args>::type>::type>(std::forward<Args>(parArgs)).data()... }.data(),
LengthArray{ arg_to_bin_safe_length(string_view(parCommand)), arg_to_bin_safe_length(std::forward<Args>(parArgs))... }.data()
);
return *this;

View file

@ -28,7 +28,7 @@
#include <cassert>
#include <vector>
#include <utility>
#include <boost/utility/string_ref.hpp>
#include <boost/utility/string_view.hpp>
#include <boost/range/iterator_range_core.hpp>
#include <ciso646>
#include <stdexcept>
@ -47,7 +47,7 @@ namespace redis {
void wait_for_disconnect ( void );
bool is_connected ( void ) const;
boost::string_ref connection_error ( void ) const;
boost::string_view connection_error ( void ) const;
Batch make_batch ( void );
Script make_script ( const std::string& parScript );

View file

@ -23,7 +23,7 @@
#include "scan_iterator.hpp"
#include <boost/optional.hpp>
#include <string>
#include <boost/utility/string_ref.hpp>
#include <boost/utility/string_view.hpp>
#include <vector>
#include <boost/range/iterator_range_core.hpp>
#include <boost/range/empty.hpp>
@ -61,26 +61,26 @@ namespace redis {
const Command& command ( void ) const { return m_command; }
//Scan
scan_range scan ( boost::string_ref parPattern=boost::string_ref() );
hscan_range hscan ( boost::string_ref parKey, boost::string_ref parPattern=boost::string_ref() );
sscan_range sscan ( boost::string_ref parKey, boost::string_ref parPattern=boost::string_ref() );
zscan_range zscan ( boost::string_ref parKey, boost::string_ref parPattern=boost::string_ref() );
scan_range scan ( boost::string_view parPattern=boost::string_view() );
hscan_range hscan ( boost::string_view parKey, boost::string_view parPattern=boost::string_view() );
sscan_range sscan ( boost::string_view parKey, boost::string_view parPattern=boost::string_view() );
zscan_range zscan ( boost::string_view parKey, boost::string_view parPattern=boost::string_view() );
//Hash
opt_string hget ( boost::string_ref parKey, boost::string_ref parField );
opt_string hget ( boost::string_view parKey, boost::string_view parField );
template <typename... Args>
opt_string_list hmget ( boost::string_ref parKey, Args&&... parArgs );
opt_string_list hmget ( boost::string_view parKey, Args&&... parArgs );
template <typename... Args>
bool hmset ( boost::string_ref parKey, Args&&... parArgs );
int hincrby ( boost::string_ref parKey, boost::string_ref parField, int parInc );
bool hmset ( boost::string_view parKey, Args&&... parArgs );
int hincrby ( boost::string_view parKey, boost::string_view parField, int parInc );
//Set
opt_string_list srandmember ( boost::string_ref parKey, int parCount );
opt_string srandmember ( boost::string_ref parKey );
opt_string_list smembers ( boost::string_ref parKey );
opt_string_list srandmember ( boost::string_view parKey, int parCount );
opt_string srandmember ( boost::string_view parKey );
opt_string_list smembers ( boost::string_view parKey );
//Sorted set
opt_string_list zrangebyscore ( boost::string_ref parKey, double parMin, bool parMinIncl, double parMax, bool parMaxIncl, bool parWithScores );
opt_string_list zrangebyscore ( boost::string_view parKey, double parMin, bool parMinIncl, double parMax, bool parMaxIncl, bool parWithScores );
//Script
bool script_flush ( void );
@ -88,12 +88,12 @@ namespace redis {
//Misc
bool flushdb ( void );
RedisInt dbsize ( void );
bool expire ( boost::string_ref parKey, RedisInt parTTL );
bool expire ( boost::string_view parKey, RedisInt parTTL );
//String
opt_string get ( boost::string_ref parKey );
bool set ( boost::string_ref parKey, boost::string_ref parField );
RedisInt incr ( boost::string_ref parKey );
opt_string get ( boost::string_view parKey );
bool set ( boost::string_view parKey, boost::string_view parField );
RedisInt incr ( boost::string_view parKey );
private:
static opt_string_list reply_to_string_list ( const Reply& parReply );
@ -102,13 +102,13 @@ namespace redis {
};
template <typename... Args>
auto IncRedis::hmget (boost::string_ref parKey, Args&&... parArgs) -> opt_string_list {
auto IncRedis::hmget (boost::string_view parKey, Args&&... parArgs) -> opt_string_list {
static_assert(sizeof...(Args) > 0, "No fields specified");
return reply_to_string_list(m_command.run("HMGET", parKey, std::forward<Args>(parArgs)...));
}
template <typename... Args>
bool IncRedis::hmset (boost::string_ref parKey, Args&&... parArgs) {
bool IncRedis::hmset (boost::string_view parKey, Args&&... parArgs) {
static_assert(sizeof...(Args) > 0, "No fields specified");
static_assert(sizeof...(Args) % 2 == 0, "Uneven number of parameters received");
const auto ret = redis::get<StatusString>(m_command.run("HMSET", parKey, std::forward<Args>(parArgs)...));

View file

@ -20,7 +20,7 @@
#include "batch.hpp"
#include "duckhandy/sequence_bt.hpp"
#include <boost/utility/string_ref.hpp>
#include <boost/utility/string_view.hpp>
#include <boost/lexical_cast.hpp>
#include <type_traits>
@ -54,33 +54,33 @@ namespace redis {
//Misc
IncRedisBatch& select ( int parIndex );
IncRedisBatch& client_setname ( boost::string_ref parName );
IncRedisBatch& client_setname ( boost::string_view parName );
template <typename... Args>
IncRedisBatch& del ( Args&&... parArgs );
//String
IncRedisBatch& set ( boost::string_ref parKey, boost::string_ref parField, ADD_Mode parMode );
IncRedisBatch& set ( boost::string_view parKey, boost::string_view parField, ADD_Mode parMode );
template <typename... Args>
IncRedisBatch& set ( boost::string_ref parKey, boost::string_ref parField, ADD_Mode parMode, Args&&... parArgs );
IncRedisBatch& set ( boost::string_view parKey, boost::string_view parField, ADD_Mode parMode, Args&&... parArgs );
//Hash
IncRedisBatch& hget ( boost::string_ref parKey, boost::string_ref parField );
IncRedisBatch& hget ( boost::string_view parKey, boost::string_view parField );
template <typename... Args>
IncRedisBatch& hmget ( boost::string_ref parKey, Args&&... parArgs );
IncRedisBatch& hmget ( boost::string_view parKey, Args&&... parArgs );
template <typename... Args>
IncRedisBatch& hmset ( boost::string_ref parKey, Args&&... parArgs );
IncRedisBatch& hincrby ( boost::string_ref parKey, boost::string_ref parField, int parInc );
IncRedisBatch& hmset ( boost::string_view parKey, Args&&... parArgs );
IncRedisBatch& hincrby ( boost::string_view parKey, boost::string_view parField, int parInc );
//Set
IncRedisBatch& srandmember ( boost::string_ref parKey, int parCount );
IncRedisBatch& srandmember ( boost::string_ref parKey );
IncRedisBatch& srandmember ( boost::string_view parKey, int parCount );
IncRedisBatch& srandmember ( boost::string_view parKey );
template <typename... Args>
IncRedisBatch& sadd ( boost::string_ref parKey, Args&&... parArgs );
IncRedisBatch& sadd ( boost::string_view parKey, Args&&... parArgs );
//Sorted set
template <typename... Args>
IncRedisBatch& zadd ( boost::string_ref parKey, ZADD_Mode parMode, bool parChange, Args&&... parArgs );
IncRedisBatch& zrangebyscore ( boost::string_ref parKey, double parMin, bool parMinIncl, double parMax, bool parMaxIncl, bool parWithScores );
IncRedisBatch& zadd ( boost::string_view parKey, ZADD_Mode parMode, bool parChange, Args&&... parArgs );
IncRedisBatch& zrangebyscore ( boost::string_view parKey, double parMin, bool parMinIncl, double parMax, bool parMaxIncl, bool parWithScores );
//Script
IncRedisBatch& script_flush ( void );
@ -95,14 +95,14 @@ namespace redis {
} //namespace implem
template <typename... Args>
IncRedisBatch& IncRedisBatch::hmget (boost::string_ref parKey, Args&&... parArgs) {
IncRedisBatch& IncRedisBatch::hmget (boost::string_view parKey, Args&&... parArgs) {
static_assert(sizeof...(Args) > 0, "No fields specified");
m_batch.run("HMGET", parKey, std::forward<Args>(parArgs)...);
return *this;
}
template <typename... Args>
IncRedisBatch& IncRedisBatch::hmset (boost::string_ref parKey, Args&&... parArgs) {
IncRedisBatch& IncRedisBatch::hmset (boost::string_view parKey, Args&&... parArgs) {
static_assert(sizeof...(Args) >= 1, "No parameters specified");
static_assert(sizeof...(Args) % 2 == 0, "Uneven number of parameters received");
m_batch.run("HMSET", parKey, std::forward<Args>(parArgs)...);
@ -110,7 +110,7 @@ namespace redis {
}
template <typename... Args>
IncRedisBatch& IncRedisBatch::sadd (boost::string_ref parKey, Args&&... parArgs) {
IncRedisBatch& IncRedisBatch::sadd (boost::string_view parKey, Args&&... parArgs) {
static_assert(sizeof...(Args) > 0, "No members specified");
m_batch.run("SADD", parKey, std::forward<Args>(parArgs)...);
return *this;
@ -124,7 +124,7 @@ namespace redis {
}
template <typename... Args>
IncRedisBatch& IncRedisBatch::zadd (boost::string_ref parKey, ZADD_Mode parMode, bool parChange, Args&&... parArgs) {
IncRedisBatch& IncRedisBatch::zadd (boost::string_view parKey, ZADD_Mode parMode, bool parChange, Args&&... parArgs) {
static_assert(sizeof...(Args) >= 1, "No score/value pairs specified");
static_assert(sizeof...(Args) % 2 == 0, "Uneven number of parameters received");
@ -150,7 +150,7 @@ namespace redis {
}
template <typename... Args>
IncRedisBatch& IncRedisBatch::set (boost::string_ref parKey, boost::string_ref parField, ADD_Mode parMode, Args&&... parArgs) {
IncRedisBatch& IncRedisBatch::set (boost::string_view parKey, boost::string_view parField, ADD_Mode parMode, Args&&... parArgs) {
using dhandy::bt::index_range;
switch(parMode) {

View file

@ -25,7 +25,7 @@
#include <type_traits>
#include <vector>
#include <cstddef>
#include <boost/utility/string_ref.hpp>
#include <boost/utility/string_view.hpp>
namespace redis {
template <typename ValueFetch>
@ -40,18 +40,18 @@ namespace redis {
class ScanIteratorBaseClass {
protected:
explicit ScanIteratorBaseClass ( Command* parCommand );
ScanIteratorBaseClass ( Command* parCommand, boost::string_ref parMatchPattern );
ScanIteratorBaseClass ( Command* parCommand, boost::string_view parMatchPattern );
~ScanIteratorBaseClass ( void ) noexcept = default;
bool is_connected ( void ) const;
Reply run ( const char* parCommand, RedisInt parScanContext, std::size_t parCount );
Reply run ( const char* parCommand, const boost::string_ref& parParameter, RedisInt parScanContext, std::size_t parCount );
Reply run ( const char* parCommand, const boost::string_view& parParameter, RedisInt parScanContext, std::size_t parCount );
bool is_equal ( const ScanIteratorBaseClass& parOther ) const { return m_command == parOther.m_command; }
private:
Command* m_command;
boost::string_ref m_match_pattern;
boost::string_view m_match_pattern;
};
} //namespace implem
@ -72,9 +72,9 @@ namespace redis {
typedef typename base_iterator::iterator_category iterator_category;
template <typename Dummy=ValueFetch, typename=typename std::enable_if<not HasScanTargetMethod<Dummy>::value>::type>
ScanIterator ( Command* parCommand, bool parEnd, boost::string_ref parMatchPattern=boost::string_ref() );
ScanIterator ( Command* parCommand, bool parEnd, boost::string_view parMatchPattern=boost::string_view() );
template <typename Dummy=ValueFetch, typename=typename std::enable_if<HasScanTargetMethod<Dummy>::value>::type>
ScanIterator ( Command* parCommand, boost::string_ref parKey, bool parEnd, boost::string_ref parMatchPattern=boost::string_ref() );
ScanIterator ( Command* parCommand, boost::string_view parKey, bool parEnd, boost::string_view parMatchPattern=boost::string_view() );
private:
template <typename T>
@ -107,17 +107,17 @@ namespace redis {
struct ScanSingleValuesInKey {
typedef T value_type;
explicit ScanSingleValuesInKey ( boost::string_ref parScanTarget ) : m_scan_target(parScanTarget) {}
explicit ScanSingleValuesInKey ( boost::string_view parScanTarget ) : m_scan_target(parScanTarget) {}
static constexpr const char* command ( void ) { return "SSCAN"; }
static constexpr const std::size_t step = 1;
static constexpr const std::size_t work_count = 10;
static const T& make_value ( const Reply* parItem );
boost::string_ref scan_target ( void ) const { return m_scan_target; }
boost::string_view scan_target ( void ) const { return m_scan_target; }
private:
boost::string_ref m_scan_target;
boost::string_view m_scan_target;
};
template <typename P, char Command, typename A=decltype(P().first), typename B=decltype(P().second)>
@ -125,17 +125,17 @@ namespace redis {
static_assert(Command == ScanCommands::HSCAN or Command == ScanCommands::ZSCAN, "Invalid scan command chosen");
typedef P value_type;
explicit ScanPairs ( boost::string_ref parScanTarget ) : m_scan_target(parScanTarget) {}
explicit ScanPairs ( boost::string_view parScanTarget ) : m_scan_target(parScanTarget) {}
static constexpr const char* command ( void ) { return ScanCommands::_from_integral(Command)._to_string(); }
static constexpr const std::size_t step = 2;
static constexpr const std::size_t work_count = 10;
static value_type make_value ( const Reply* parItem );
boost::string_ref scan_target ( void ) const { return m_scan_target; }
boost::string_view scan_target ( void ) const { return m_scan_target; }
private:
boost::string_ref m_scan_target;
boost::string_view m_scan_target;
};
} //namespace redis

View file

@ -25,7 +25,7 @@ namespace redis {
template <typename ValueFetch>
template <typename Dummy, typename>
ScanIterator<ValueFetch>::ScanIterator (Command* parCommand, bool parEnd, boost::string_ref parMatchPattern) :
ScanIterator<ValueFetch>::ScanIterator (Command* parCommand, bool parEnd, boost::string_view parMatchPattern) :
implem::ScanIteratorBaseClass(parCommand, parMatchPattern),
implem::ScanIteratorBaseIterator<ValueFetch>(),
ValueFetch(),
@ -45,7 +45,7 @@ namespace redis {
template <typename ValueFetch>
template <typename Dummy, typename>
ScanIterator<ValueFetch>::ScanIterator (Command* parCommand, boost::string_ref parKey, bool parEnd, boost::string_ref parMatchPattern) :
ScanIterator<ValueFetch>::ScanIterator (Command* parCommand, boost::string_view parKey, bool parEnd, boost::string_view parMatchPattern) :
implem::ScanIteratorBaseClass(parCommand, parMatchPattern),
implem::ScanIteratorBaseIterator<ValueFetch>(),
ValueFetch(parKey),

View file

@ -21,7 +21,7 @@
#include "batch.hpp"
#include "duckhandy/lexical_cast.hpp"
#include "duckhandy/sequence_bt.hpp"
#include <boost/utility/string_ref.hpp>
#include <boost/utility/string_view.hpp>
#include <tuple>
#include <cassert>
#include <ciso646>
@ -33,7 +33,7 @@ namespace redis {
public:
Script ( void );
Script ( Script&& ) = default;
Script ( boost::string_ref parSha1, ScriptManager& parManager );
Script ( boost::string_view parSha1, ScriptManager& parManager );
~Script ( void ) noexcept = default;
template <typename... Keys, typename... Values>
@ -45,7 +45,7 @@ namespace redis {
template <typename... Keys, typename... Values, std::size_t... KeyIndices, std::size_t... ValueIndices>
void run_with_indices ( Batch& parBatch, const std::tuple<Keys...>& parKeys, const std::tuple<Values...>& parValues, dhandy::bt::index_seq<KeyIndices...>, dhandy::bt::index_seq<ValueIndices...> );
boost::string_ref m_sha1;
boost::string_view m_sha1;
ScriptManager* m_manager;
};

View file

@ -22,7 +22,7 @@
#if defined(WITH_CRYPTOPP)
# define MAKE_SHA1_WITH_CRYPTOPP
#endif
#include <boost/utility/string_ref.hpp>
#include <boost/utility/string_view.hpp>
#if defined(MAKE_SHA1_WITH_CRYPTOPP)
# include <set>
#else
@ -30,7 +30,6 @@
#endif
#include <string>
#include <array>
#include <boost/utility/string_ref.hpp>
namespace redis {
class Command;
@ -39,12 +38,12 @@ namespace redis {
public:
explicit ScriptManager ( Command* parCommand );
boost::string_ref submit_lua_script ( const std::string& parScript );
boost::string_view submit_lua_script ( const std::string& parScript );
private:
using Sha1Array = std::array<char, 40>;
boost::string_ref add_lua_script_ifn ( const std::string& parScript );
boost::string_view add_lua_script_ifn ( const std::string& parScript );
Command* const m_command;
#if defined(MAKE_SHA1_WITH_CRYPTOPP)
@ -54,7 +53,7 @@ namespace redis {
#endif
};
inline boost::string_ref ScriptManager::submit_lua_script (const std::string& parScript) {
inline boost::string_view ScriptManager::submit_lua_script (const std::string& parScript) {
return add_lua_script_ifn(parScript);
}
} //namespace redis

View file

@ -199,7 +199,7 @@ namespace redis {
return connected;
}
boost::string_ref AsyncConnection::connection_error() const {
boost::string_view AsyncConnection::connection_error() const {
return m_local_data->connect_err_msg;
}

View file

@ -21,7 +21,7 @@
#include <memory>
#include <string>
#include <cstdint>
#include <boost/utility/string_ref.hpp>
#include <boost/utility/string_view.hpp>
struct redisAsyncContext;
struct ev_loop;
@ -44,7 +44,7 @@ namespace redis {
void wait_for_disconnect ( void );
bool is_connected ( void ) const;
boost::string_ref connection_error ( void ) const;
boost::string_view connection_error ( void ) const;
void wakeup_event_thread ( void );
std::mutex& event_mutex ( void );
redisAsyncContext* connection ( void );

View file

@ -77,7 +77,7 @@ namespace redis {
return m_local_data->async_connection.is_connected();
}
boost::string_ref Command::connection_error() const {
boost::string_view Command::connection_error() const {
return m_local_data->async_connection.connection_error();
}

View file

@ -81,45 +81,45 @@ namespace redis {
return m_command.make_batch();
}
auto IncRedis::scan (boost::string_ref parPattern) -> scan_range {
auto IncRedis::scan (boost::string_view parPattern) -> scan_range {
return scan_range(scan_iterator(&m_command, false, parPattern), scan_iterator(&m_command, true));
}
auto IncRedis::hscan (boost::string_ref parKey, boost::string_ref parPattern) -> hscan_range {
auto IncRedis::hscan (boost::string_view parKey, boost::string_view parPattern) -> hscan_range {
return hscan_range(hscan_iterator(&m_command, parKey, false, parPattern), hscan_iterator(&m_command, parKey, true));
}
auto IncRedis::sscan (boost::string_ref parKey, boost::string_ref parPattern) -> sscan_range {
auto IncRedis::sscan (boost::string_view parKey, boost::string_view parPattern) -> sscan_range {
return sscan_range(sscan_iterator(&m_command, parKey, false, parPattern), sscan_iterator(&m_command, parKey, true));
}
auto IncRedis::zscan (boost::string_ref parKey, boost::string_ref parPattern) -> zscan_range {
auto IncRedis::zscan (boost::string_view parKey, boost::string_view parPattern) -> zscan_range {
return zscan_range(zscan_iterator(&m_command, parKey, false, parPattern), zscan_iterator(&m_command, parKey, true));
}
auto IncRedis::hget (boost::string_ref parKey, boost::string_ref parField) -> opt_string {
auto IncRedis::hget (boost::string_view parKey, boost::string_view parField) -> opt_string {
return optional_string(m_command.run("HGET", parKey, parField));
}
int IncRedis::hincrby (boost::string_ref parKey, boost::string_ref parField, int parInc) {
int IncRedis::hincrby (boost::string_view parKey, boost::string_view parField, int parInc) {
const auto inc = dhandy::lexical_cast<std::string>(parInc);
auto reply = m_command.run("HINCRBY", parKey, parField, inc);
return get_integer(reply);
}
auto IncRedis::srandmember (boost::string_ref parKey, int parCount) -> opt_string_list {
auto IncRedis::srandmember (boost::string_view parKey, int parCount) -> opt_string_list {
return optional_string_list(m_command.run("SRANDMEMBER", parKey, dhandy::lexical_cast<std::string>(parCount)));
}
auto IncRedis::srandmember (boost::string_ref parKey) -> opt_string {
auto IncRedis::srandmember (boost::string_view parKey) -> opt_string {
return optional_string(m_command.run("SRANDMEMBER", parKey));
}
auto IncRedis::smembers (boost::string_ref parKey) -> opt_string_list {
auto IncRedis::smembers (boost::string_view parKey) -> opt_string_list {
return optional_string_list(m_command.run("SMEMBERS", parKey));
}
auto IncRedis::zrangebyscore (boost::string_ref parKey, double parMin, bool parMinIncl, double parMax, bool parMaxIncl, bool parWithScores) -> opt_string_list {
auto IncRedis::zrangebyscore (boost::string_view parKey, double parMin, bool parMinIncl, double parMax, bool parMaxIncl, bool parWithScores) -> opt_string_list {
auto batch = make_batch();
batch.zrangebyscore(parKey, parMin, parMinIncl, parMax, parMaxIncl, parWithScores);
assert(batch.replies().size() == 1);
@ -141,7 +141,7 @@ namespace redis {
return ret;
}
bool IncRedis::expire (boost::string_ref parKey, RedisInt parTTL) {
bool IncRedis::expire (boost::string_view parKey, RedisInt parTTL) {
const auto ret = redis::get<RedisInt>(m_command.run("EXPIRE", parKey, dhandy::lexical_cast<std::string>(parTTL)));
return (ret == 1 ? true : false);
}
@ -150,11 +150,11 @@ namespace redis {
return optional_string_list(parReply);
}
auto IncRedis::get (boost::string_ref parKey) -> opt_string {
auto IncRedis::get (boost::string_view parKey) -> opt_string {
return optional_string(m_command.run("GET", parKey));
}
bool IncRedis::set (boost::string_ref parKey, boost::string_ref parField) {
bool IncRedis::set (boost::string_view parKey, boost::string_view parField) {
auto batch = make_batch();
batch.set(parKey, parField, IncRedisBatch::ADD_None);
assert(batch.replies().size() == 1);
@ -162,7 +162,7 @@ namespace redis {
return ret.is_ok();
}
RedisInt IncRedis::incr (boost::string_ref parKey) {
RedisInt IncRedis::incr (boost::string_view parKey) {
const auto ret = redis::get<RedisInt>(m_command.run("INCR", parKey));
return ret;
}

View file

@ -49,32 +49,32 @@ namespace redis {
return *this;
}
IncRedisBatch& IncRedisBatch::client_setname (boost::string_ref parName) {
IncRedisBatch& IncRedisBatch::client_setname (boost::string_view parName) {
m_batch.run("CLIENT", "SETNAME", parName);
return *this;
}
IncRedisBatch& IncRedisBatch::hget (boost::string_ref parKey, boost::string_ref parField) {
IncRedisBatch& IncRedisBatch::hget (boost::string_view parKey, boost::string_view parField) {
m_batch.run("HGET", parKey, parField);
return *this;
}
IncRedisBatch& IncRedisBatch::hincrby (boost::string_ref parKey, boost::string_ref parField, int parInc) {
IncRedisBatch& IncRedisBatch::hincrby (boost::string_view parKey, boost::string_view parField, int parInc) {
m_batch.run("HINCRBY", parKey, parField, dhandy::lexical_cast<std::string>(parInc));
return *this;
}
IncRedisBatch& IncRedisBatch::srandmember (boost::string_ref parKey, int parCount) {
IncRedisBatch& IncRedisBatch::srandmember (boost::string_view parKey, int parCount) {
m_batch.run("SRANDMEMBER", parKey, dhandy::lexical_cast<std::string>(parCount));
return *this;
}
IncRedisBatch& IncRedisBatch::srandmember (boost::string_ref parKey) {
IncRedisBatch& IncRedisBatch::srandmember (boost::string_view parKey) {
m_batch.run("SRANDMEMBER", parKey);
return *this;
}
IncRedisBatch& IncRedisBatch::set (boost::string_ref parKey, boost::string_ref parField, ADD_Mode parMode) {
IncRedisBatch& IncRedisBatch::set (boost::string_view parKey, boost::string_view parField, ADD_Mode parMode) {
switch(parMode) {
case ADD_None:
m_batch.run("SET", parKey, parField);
@ -89,7 +89,7 @@ namespace redis {
return *this;
}
IncRedisBatch& IncRedisBatch::zrangebyscore (boost::string_ref parKey, double parMin, bool parMinIncl, double parMax, bool parMaxIncl, bool parWithScores) {
IncRedisBatch& IncRedisBatch::zrangebyscore (boost::string_view parKey, double parMin, bool parMinIncl, double parMax, bool parMaxIncl, bool parWithScores) {
auto lower_bound = make_boundary(parMin, not parMinIncl);
auto upper_bound = make_boundary(parMax, not parMaxIncl);

View file

@ -25,11 +25,11 @@
namespace redis {
namespace implem {
ScanIteratorBaseClass::ScanIteratorBaseClass (Command* parCommand) :
ScanIteratorBaseClass(parCommand, boost::string_ref())
ScanIteratorBaseClass(parCommand, boost::string_view())
{
}
ScanIteratorBaseClass::ScanIteratorBaseClass (Command* parCommand, boost::string_ref parMatchPattern) :
ScanIteratorBaseClass::ScanIteratorBaseClass (Command* parCommand, boost::string_view parMatchPattern) :
m_command(parCommand),
m_match_pattern(parMatchPattern)
{
@ -50,7 +50,7 @@ namespace redis {
return m_command->run(parCommand, scan_context, "MATCH", m_match_pattern, "COUNT", count_hint);
}
Reply ScanIteratorBaseClass::run (const char* parCommand, const boost::string_ref& parParameter, RedisInt parScanContext, std::size_t parCount) {
Reply ScanIteratorBaseClass::run (const char* parCommand, const boost::string_view& parParameter, RedisInt parScanContext, std::size_t parCount) {
const auto scan_context = dhandy::lexical_cast<std::string>(parScanContext);
const auto count_hint = dhandy::lexical_cast<std::string>(parCount);
if (m_match_pattern.empty())

View file

@ -24,7 +24,7 @@ namespace redis {
{
}
Script::Script (boost::string_ref parSha1, ScriptManager& parManager) :
Script::Script (boost::string_view parSha1, ScriptManager& parManager) :
m_sha1(parSha1),
m_manager(&parManager)
{

View file

@ -45,11 +45,11 @@ namespace redis {
}
#if defined(MAKE_SHA1_WITH_CRYPTOPP)
boost::string_ref ScriptManager::add_lua_script_ifn (const std::string& parScript) {
boost::string_view ScriptManager::add_lua_script_ifn (const std::string& parScript) {
assert(m_command->is_connected());
if (parScript.empty())
return boost::string_ref();
return boost::string_view();
using dhandy::lexical_cast;
@ -75,7 +75,7 @@ namespace redis {
auto it_found = m_known_hashes.find(sha1_array);
const bool was_present = (m_known_hashes.end() != it_found);
if (was_present) {
return boost::string_ref(it_found->data(), it_found->size());
return boost::string_view(it_found->data(), it_found->size());
}
auto reply = m_command->run("SCRIPT", "LOAD", parScript);
@ -85,16 +85,16 @@ namespace redis {
const auto it_inserted = m_known_hashes.insert(it_found, sha1_array);
(void)reply;
return boost::string_ref(it_inserted->data(), it_inserted->size());
return boost::string_view(it_inserted->data(), it_inserted->size());
}
#else
boost::string_ref ScriptManager::add_lua_script_ifn (const std::string& parScript) {
boost::string_view ScriptManager::add_lua_script_ifn (const std::string& parScript) {
assert(m_command->is_connected());
auto it_found = m_known_scripts.find(parScript);
const bool was_present = (m_known_scripts.end() != it_found);
if (was_present) {
return boost::string_ref(it_found->second.data(), it_found->second.size());
return boost::string_view(it_found->second.data(), it_found->second.size());
}
auto reply = m_command->run("SCRIPT", "LOAD", parScript);
@ -105,7 +105,7 @@ namespace redis {
std::copy(sha1_str.begin(), sha1_str.end(), sha1_array.begin());
auto it_inserted = m_known_scripts.insert(it_found, std::make_pair(parScript, sha1_array));
return boost::string_ref(it_inserted->second.data(), it_inserted->second.size());
return boost::string_view(it_inserted->second.data(), it_inserted->second.size());
}
#endif
} //namespace redis