test redis_key, redis_string, redis_hash ok

This commit is contained in:
ubuntu14 2015-01-15 09:12:41 -08:00
parent a674a864ab
commit e143998522
38 changed files with 3017 additions and 83 deletions

View File

@ -1,6 +1,11 @@
修改历史列表:
------------------------------------------------------------------------
271) 2015.1.15
271.1) bugfix: beanstalk 客户端库当采用超时方式获取消息时不应记录出错日志
271.2) feature: redis 客户端库的所有与 redis_string 相关的功能测试通过
271.3) feature: redis 客户端库的所有与 redis_hash/redis_key 相关的功能测试通过
270) 2015.1.7
270.1) feature: socket_stream 类增加了 get_tcp_non_blocking 方法用于判断当前
套接字是否是非阻塞模式(目前仅支持 UNIX 平台)

View File

@ -124,7 +124,10 @@ public:
* > 0
* == 0
* @return {unsigned long long} > 0
*
*
* 0 get_error() TIMED_OUT
* DEADLINE_SOON ttr
* () delete_id
*/
unsigned long long reserve(string& buf, int timeout = -1);

View File

@ -50,16 +50,22 @@ public:
* @return {bool} hmget_result
* get_result redis_result
*/
bool hmget(const char* key, const std::vector<string>& names);
bool hmget(const char* key, const std::vector<char*>& names);
bool hmget(const char* key, const std::vector<const char*>& names);
bool hmget(const char* key, const std::vector<int>& names);
bool hmget(const char* key, const std::vector<string>& names,
std::vector<string>* result = NULL);
bool hmget(const char* key, const std::vector<char*>& names,
std::vector<string>* result = NULL);
bool hmget(const char* key, const std::vector<const char*>& names,
std::vector<string>* result = NULL);
bool hmget(const char* key, const std::vector<int>& names,
std::vector<string>* result = NULL);
bool hmget(const char* key, const char* names[], size_t argc);
bool hmget(const char* key, const int names[], size_t argc);
bool hmget(const char* key, const char* names[],
const size_t lens[], size_t argc);
bool hmget(const string& req);
bool hmget(const char* key, const char* names[], size_t argc,
std::vector<string>* result = NULL);
bool hmget(const char* key, const int names[], size_t argc,
std::vector<string>* result = NULL);
bool hmget(const char* key, const char* names[], const size_t lens[],
size_t argc, std::vector<string>* result = NULL);
bool hmget(const string& req, std::vector<string>* result = NULL);
/**
* hmget true hmget
@ -71,7 +77,9 @@ public:
* 使 \0
*
*/
const char* hmget_result(size_t i, size_t* len = NULL) const;
const char* hmget_value(size_t i, size_t* len = NULL) const;
const redis_result* hmget_result(size_t i) const;
size_t hmget_size() const;
/////////////////////////////////////////////////////////////////////

View File

@ -28,6 +28,7 @@ all:
@(cd md5; make)
@(cd http_server; make)
@(cd beanstalk; make)
@(cd beanstalk2; make)
@(cd master; make)
@(cd master_aio_proxy; make)
@(cd benchmark; make)
@ -74,6 +75,7 @@ clean:
@(cd md5; make clean)
@(cd http_server; make clean)
@(cd beanstalk; make clean)
@(cd beanstalk2; make clean)
@(cd master; make clean)
@(cd master_aio_proxy; make clean)
@(cd benchmark; make clean)

View File

@ -0,0 +1,5 @@
#UTIL = $(wildcard ../*.cpp)
base_path = ../..
PROG = beanstalk
CFLAGS += -I../
include ../Makefile.in

View File

@ -0,0 +1,31 @@
========================================================================
控制台应用程序 : beanstalk 项目概况
========================================================================
应用程序向导已为您创建了这个 beanstalk 应用程序。
此文件包含组成 beanstalk 应用程序
的每个文件的内容摘要。
beanstalk.vcproj
这是用应用程序向导生成的 VC++ 项目的主项目文件。
它包含有关生成此文件的 Visual C++ 版本的信息,以及
有关用应用程序向导选择的
平台、配置和项目功能的信息。
beanstalk.cpp
这是主应用程序源文件。
/////////////////////////////////////////////////////////////////////////////
其他标准文件:
StdAfx.h、StdAfx.cpp
这些文件用于生成名为 beanstalk.pch
的预编译头(PCH)文件以及名为 StdAfx.obj 的预编译类型文件。
/////////////////////////////////////////////////////////////////////////////
其他注释:
应用程序向导使用 "TODO:" 注释指示应添加或自定义的源代码部分。
/////////////////////////////////////////////////////////////////////////////

View File

@ -0,0 +1,84 @@
// beanstalk.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include "util.h"
static char __addr[64];
static const char* __tube = "zsxxsz";
static int __max = 100;
// 接收队列消息的消费者线程
static void consumer(void)
{
acl::beanstalk conn(__addr, 10);
// 从指定消息队列中接收消息
if (conn.watch(__tube) == false)
{
printf("watch %s faile\r\n", __tube);
return;
}
acl::string buf;
unsigned long long id;
// 超时接收一条消息
if ((id = conn.reserve(buf)) == 0)
printf("reserve failed, error: %s\r\n", conn.get_error());
else
{
printf("id: %llu, buf: %s\r\n", id, buf.c_str());
conn.delete_id(id);
}
// 阻塞接收一条消息
if ((id = conn.reserve(buf, 1)) == 0)
printf("reserve failed, error: %s\r\n", conn.get_error());
else
printf("id: %llu, buf: %s\r\n", id, buf.c_str());
}
static void usage(const char* procname)
{
printf("usage: %s -h [help] -s beanstalk_addr [127.0.0.1:11300] -n max_count\r\n", procname);
}
int main(int argc, char* argv[])
{
#if WIN32
acl::acl_cpp_init();
#endif
acl::log::stdout_open(true);
snprintf(__addr, sizeof(__addr), "127.0.0.1:11300");
int ch;
while ((ch = getopt(argc, argv, "hs:n:")) > 0)
{
switch (ch)
{
case 'h':
usage(argv[0]);
return 0;
case 's':
snprintf(__addr, sizeof(__addr), "%s", optarg);
break;
case 'n':
__max = atoi(optarg);
if (__max <= 0)
__max = 1;
break;
default:
break;
}
}
consumer();
#ifdef WIN32
printf("enter any key to exit\r\n");
getchar();
#endif
return 0;
}

View File

@ -0,0 +1,269 @@
<?xml version="1.0" encoding="gb2312"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="beanstalk"
ProjectGUID="{1509DA30-29B0-4B73-921A-BBBD9E5608BE}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\;..\..\..\lib_acl_cpp\include;..\..\..\lib_acl\include"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;VC2003"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="3"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/beanstalk.exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/beanstalk.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\;..\..\..\lib_acl_cpp\include;..\..\..\lib_acl\include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;VC2003"
RuntimeLibrary="0"
UsePrecompiledHeader="3"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/beanstalk.exe"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="DebugDll|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\;..\..\..\lib_acl_cpp\include;..\..\..\lib_acl\include"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;VC2003;ACL_DLL"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="3"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/beanstalk.exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/beanstalk.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="ReleaseDll|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\;..\..\..\lib_acl_cpp\include;..\..\..\lib_acl\include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;VC2003;ACL_DLL"
RuntimeLibrary="2"
UsePrecompiledHeader="3"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/beanstalk.exe"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Ô´Îļþ"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File
RelativePath=".\beanstalk.cpp">
</File>
<File
RelativePath=".\stdafx.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
<FileConfiguration
Name="DebugDll|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
<FileConfiguration
Name="ReleaseDll|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
</File>
<File
RelativePath="..\util.cpp">
</File>
</Filter>
<Filter
Name="Í·Îļþ"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
<File
RelativePath=".\stdafx.h">
</File>
<File
RelativePath="..\util.h">
</File>
</Filter>
<Filter
Name="×ÊÔ´Îļþ"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
</Filter>
<File
RelativePath=".\ReadMe.txt">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,407 @@
<?xml version="1.0" encoding="gb2312"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="beanstalk"
ProjectGUID="{1509DA30-29B0-4B73-921A-BBBD9E5608BE}"
Keyword="Win32Proj"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\;..\..\..\lib_acl_cpp\include;..\..\..\lib_acl\include"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/beanstalk.exe"
LinkIncremental="2"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(OutDir)/beanstalk.pdb"
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\;..\..\..\lib_acl_cpp\include;..\..\..\lib_acl\include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="0"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/beanstalk.exe"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="DebugDll|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\;..\..\..\lib_acl_cpp\include;..\..\..\lib_acl\include"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;VC2003;ACL_DLL"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/beanstalk.exe"
LinkIncremental="2"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(OutDir)/beanstalk.pdb"
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="ReleaseDll|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\;..\..\..\lib_acl_cpp\include;..\..\..\lib_acl\include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;VC2003;ACL_DLL"
RuntimeLibrary="2"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/beanstalk.exe"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Ô´Îļþ"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\beanstalk.cpp"
>
</File>
<File
RelativePath=".\stdafx.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="DebugDll|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="ReleaseDll|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\util.cpp"
>
</File>
</Filter>
<Filter
Name="Í·Îļþ"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\stdafx.h"
>
</File>
<File
RelativePath="..\util.h"
>
</File>
</Filter>
<Filter
Name="×ÊÔ´Îļþ"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
<File
RelativePath=".\ReadMe.txt"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,8 @@
// stdafx.cpp : 只包括标准包含文件的源文件
// beanstalk.pch 将成为预编译头
// stdafx.obj 将包含预编译类型信息
#include "stdafx.h"
// TODO: 在 STDAFX.H 中
//引用任何所需的附加头文件,而不是在此文件中引用

View File

@ -0,0 +1,14 @@
// stdafx.h : 标准系统包含文件的包含文件,
// 或是常用但不常更改的项目特定的包含文件
//
#pragma once
#include "lib_acl.h"
#include "acl_cpp/lib_acl.hpp"
// TODO: 在此处引用程序要求的附加头文件
#ifdef WIN32
#define snprintf _snprintf
#endif

View File

@ -0,0 +1,3 @@
#!/bin/sh
valgrind --tool=memcheck --leak-check=yes -v ./beanstalk

View File

@ -0,0 +1,9 @@
all:
@(cd redis_key; make)
@(cd redis_string; make)
@(cd redis_hash; make)
clean:
@(cd redis_key; make clean)
@(cd redis_string; make clean)
@(cd redis_hash; make clean)

View File

@ -0,0 +1,3 @@
base_path = ../../..
PROG = redis_hash
include ../../Makefile.in

Binary file not shown.

View File

@ -0,0 +1,408 @@
#include "stdafx.h"
static acl::string __keypre("hash_test_key");
static void test_hmset(acl::redis_hash& option, int n)
{
acl::string key, attr1, attr2, attr3;
acl::string val1, val2, val3;
std::map<acl::string, acl::string> attrs;
for (int i = 0; i < n; i++)
{
key.format("%s_%d", __keypre.c_str(), i);
attr1.format("attr1");
attr2.format("attr2");
attr3.format("attr3");
val1.format("val1_%s", attr1.c_str());
val2.format("val2_%s", attr2.c_str());
val3.format("val3_%s", attr3.c_str());
attrs[attr1] = val1;
attrs[attr2] = val2;
attrs[attr3] = val3;
if (option.hmset(key.c_str(), attrs) == false)
{
printf("hmset error, key: %s\r\n", key.c_str());
break;
}
else if (i < 10)
{
printf("hmset ok, key: %s, %s=%s, %s=%s, %s=%s\r\n",
key.c_str(), attr1.c_str(), val1.c_str(),
attr2.c_str(), val2.c_str(),
attr3.c_str(), val3.c_str());
}
attrs.clear();
}
}
static void test_hmget(acl::redis_hash& option, int n)
{
acl::string key, attr1, attr2, attr3;
const char* attrs[3];
std::vector<acl::string> result;
for (int i = 0; i < n; i++)
{
key.format("%s_%d", __keypre.c_str(), i);
attr1.format("attr1");
attr2.format("attr2");
attr3.format("attr3");
attrs[0] = attr1.c_str();
attrs[1] = attr2.c_str();
attrs[2] = attr3.c_str();
result.clear();
if (option.hmget(key, attrs, 3, &result) == false)
{
printf("hmget error\r\n");
break;
}
else if (i >= 10)
continue;
size_t size = option.hmget_size();
printf("size: %lu, key: %s\r\n", (unsigned long) size,
key.c_str());
size_t j;
for (j = 0; j < size; j++)
{
const char* val = option.hmget_value(j);
printf("hmget ok, %s=%s\r\n",
attrs[j], val ? val : "null");
}
std::vector<acl::string>::const_iterator it= result.begin();
for (j = 0; it != result.end(); ++it, j++)
printf("hmget %s=%s\r\n", attrs[j], (*it).c_str());
}
}
static void test_hset(acl::redis_hash& option, int n)
{
acl::string key;
acl::string attr, value;
for (int i = 0; i < n; i++)
{
key.format("%s_%d", __keypre.c_str(), i);
attr.format("attr1");
value.format("value_%s", key.c_str());
if (option.hset(key.c_str(), attr.c_str(),
value.c_str()) < 0)
{
printf("hset key: %s error\r\n", key.c_str());
break;
}
else if (i < 10)
printf("hset key: %s ok\r\n", key.c_str());
}
}
static void test_hsetnx(acl::redis_hash& option, int n)
{
acl::string key;
acl::string attr, value;
int ret;
for (int i = 0; i < n; i++)
{
key.format("%s_%d", __keypre.c_str(), i);
attr.format("attr4");
value.format("value_%s", key.c_str());
if ((ret = option.hsetnx(key.c_str(), attr.c_str(),
value.c_str())) <0)
{
printf("hsetnx key: %s error\r\n", key.c_str());
break;
}
else if (i < 10)
printf("hsetnx key: %s ok, ret: %d\r\n",
key.c_str(), ret);
}
}
static void test_hget(acl::redis_hash& option, int n)
{
acl::string key;
acl::string attr, value;
for (int i = 0; i < n; i++)
{
key.format("%s_%d", __keypre.c_str(), i);
attr.format("attr1");
value.clear();
if (option.hget(key.c_str(), attr.c_str(), value) == false)
{
printf("hget key: %s, attr: %s\r\n", key.c_str(),
attr.c_str());
break;
}
else if (i >= 10)
continue;
printf("key: %s, attr: %s, value: %s, len: %d\r\n",
key.c_str(), attr.c_str(), value.c_str(),
(int) value.length());
}
}
static void test_hgetall(acl::redis_hash& option, int n)
{
acl::string key;
std::map<acl::string, acl::string> result;
for (int i = 0; i < n; i++)
{
key.format("%s_%d", __keypre.c_str(), i);
result.clear();
if (option.hgetall(key.c_str(), result) == false)
{
printf("hgetall key: %s\r\n", key.c_str());
break;
}
else if (i >= 10)
continue;
std::map<acl::string, acl::string>::const_iterator cit;
printf("key: %s\r\n", key.c_str());
for (cit = result.begin(); cit != result.end(); ++cit)
{
printf("attr: %s=%s\r\n", cit->first.c_str(),
cit->second.c_str());
}
}
}
static void test_hdel(acl::redis_hash& option, int n)
{
acl::string key, attr;
for (int i = 0; i < n; i++)
{
key.format("%s_%d", __keypre.c_str(), i);
attr.format("attr1");
int ret = option.hdel(key.c_str(), attr.c_str(), NULL);
if (ret < 0)
{
printf("hdel key: %s error\r\n", key.c_str());
break;
}
else if (i < 10)
printf("hdel ok, key: %s\r\n", key.c_str());
}
}
static void test_hincrby(acl::redis_hash& option, int n)
{
acl::string key, attr;
long long int result;
for (int i = 0; i < n; i++)
{
key.format("hincr_%s_%d", __keypre.c_str(), i);
attr.format("attr1");
if (option.hincrby(key.c_str(), attr.c_str(), 10,
&result) == false)
{
printf("hincrby error, key: %s, attr: %s\r\n",
key.c_str(), attr.c_str());
break;
}
else if (i < 10)
printf("hincrby, key: %s, attr: %s, result: %lld\r\n",
key.c_str(), attr.c_str(), result);
}
}
static void test_hincrbyfloat(acl::redis_hash& option, int n)
{
acl::string key, attr;
double result;
for (int i = 0; i < n; i++)
{
key.format("hincrbyfloat_%s_%d", __keypre.c_str(), i);
attr.format("attr1");
if (option.hincrbyfloat(key.c_str(), attr.c_str(),
8.8, &result) == false)
{
printf("hincrbyfloat error, key: %s\r\n", key.c_str());
break;
}
else if (i >= 10)
continue;
printf("hincrbyfloat ok, key: %s, attr: %s, result: %.2f\r\n",
key.c_str(), attr.c_str(), result);
}
}
static void test_hkeys(acl::redis_hash& option, int n)
{
acl::string key;
std::vector<acl::string> attrs;
for (int i = 0; i < n; i++)
{
key.format("%s_%d", __keypre.c_str(), i);
attrs.clear();
if (option.hkeys(key.c_str(), attrs) == false)
{
printf("hkeys error, key: %s\r\n", key.c_str());
break;
}
else if (i >= 10)
continue;
printf("hkeys ok, key: %s\r\n", key.c_str());
std::vector<acl::string>::const_iterator cit;
for (cit = attrs.begin(); cit != attrs.end(); ++cit)
{
if (cit != attrs.begin())
printf(", ");
printf("%s", (*cit).c_str());
}
printf("\r\n");
}
}
static void test_hexists(acl::redis_hash& option, int n)
{
acl::string key, attr;
for (int i = 0; i < n; i++)
{
key.format("%s_%d", __keypre.c_str(), i);
attr.format("attr1");
if (option.hexists(key.c_str(), attr.c_str()) == false)
printf("no hexists key: %s\r\n", key.c_str());
else
printf("hexists key: %s, attr: %s\r\n",
key.c_str(), attr.c_str());
}
}
static void test_hlen(acl::redis_hash& option, int n)
{
acl::string key;
for (int i = 0; i < n; i++)
{
key.format("%s_%d", __keypre.c_str(), i);
int ret = option.hlen(key.c_str());
if (ret < 0)
{
printf("hlen error, key: %s\r\n", key.c_str());
break;
}
else if (i < 10)
printf("hlen: %s's value's length: %d\r\n",
key.c_str(), ret);
}
}
static void usage(const char* procname)
{
printf("usage: %s -h[help]\r\n"
"-s redis_addr[127.0.0.1:6380]\r\n"
"-n count\r\n"
"-C connect_timeout[default: 10]\r\n"
"-T rw_timeout[default: 10]\r\n"
"-a cmd\r\n",
procname);
}
int main(int argc, char* argv[])
{
int ch, n = 1, conn_timeout = 10, rw_timeout = 10;
acl::string addr("127.0.0.1:6380"), cmd;
while ((ch = getopt(argc, argv, "hs:n:C:T:a:")) > 0)
{
switch (ch)
{
case 'h':
usage(argv[0]);
return 0;
case 's':
addr = optarg;
break;
case 'n':
n = atoi(optarg);
break;
case 'C':
conn_timeout = atoi(optarg);
break;
case 'T':
rw_timeout = atoi(optarg);
break;
case 'a':
cmd = optarg;
break;
default:
break;
}
}
acl::acl_cpp_init();
acl::redis_client client(addr.c_str(), conn_timeout, rw_timeout);
acl::redis_hash option(client);
if (cmd == "hmset")
test_hmset(option, n);
else if (cmd == "hmget")
test_hmget(option, n);
else if (cmd == "hset")
test_hset(option, n);
else if (cmd == "hsetnx")
test_hsetnx(option, n);
else if (cmd == "hget")
test_hget(option, n);
else if (cmd == "hgetall")
test_hgetall(option, n);
else if (cmd == "hdel")
test_hdel(option, n);
else if (cmd == "hincrby")
test_hincrby(option, n);
else if (cmd == "hincrbyfloat")
test_hincrbyfloat(option, n);
else if (cmd == "hkeys")
test_hkeys(option, n);
else if (cmd == "hexists")
test_hexists(option, n);
else if (cmd == "hlen")
test_hlen(option, n);
else if (cmd == "all")
{
test_hmset(option, n);
test_hmget(option, n);
test_hset(option, n);
test_hsetnx(option, n);
test_hget(option, n);
test_hgetall(option, n);
test_hincrby(option, n);
test_hincrbyfloat(option, n);
test_hkeys(option, n);
test_hexists(option, n);
test_hlen(option, n);
test_hdel(option, n);
}
else
printf("unknown cmd: %s\r\n", cmd.c_str());
#ifdef WIN32
printf("enter any key to exit\r\n");
getchar();
#endif
return 0;
}

View File

@ -0,0 +1,273 @@
<?xml version="1.0" encoding="gb2312"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="redis_hash"
ProjectGUID="{2DABFAD1-114B-4F96-9185-DC0C56A3662D}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\include;..\..\..\..\lib_acl\include"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;VC2003"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="3"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="lib_acl_vc2003d.lib ws2_32.lib"
OutputFile="$(OutDir)/redis_hash.exe"
LinkIncremental="2"
AdditionalLibraryDirectories="..\..\..\..\lib\win32;..\..\..\..\dist\lib\win32"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/redis_hash.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\..\..\include;..\..\..\..\lib_acl\include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;VC2003"
RuntimeLibrary="0"
UsePrecompiledHeader="3"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="ws2_32.lib wsock32.lib lib_acl_vc2003.lib"
OutputFile="$(OutDir)/redis_hash.exe"
LinkIncremental="1"
AdditionalLibraryDirectories="..\..\..\..\lib\win32;..\..\..\..\dist\lib\win32"
GenerateDebugInformation="TRUE"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="DebugDll|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\include;..\..\..\..\lib_acl\include"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;VC2003;ACL_CPP_DLL;ACL_DLL"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="3"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="ws2_32.lib"
OutputFile="$(OutDir)/redis_hash.exe"
LinkIncremental="2"
AdditionalLibraryDirectories="..\..\..\..\lib\win32"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/redis_hash.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Releasedll|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\include;..\..\..\..\lib_acl\include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;VC2003;ACL_CPP_DLL;ACL_DLL"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="2"
UsePrecompiledHeader="3"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="ws2_32.lib"
OutputFile="$(OutDir)/redis_hash.exe"
LinkIncremental="2"
AdditionalLibraryDirectories="..\..\..\..\lib\win32"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/redis_hash.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Ô´Îļþ"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File
RelativePath=".\stdafx.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
<FileConfiguration
Name="DebugDll|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
<FileConfiguration
Name="Releasedll|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
</File>
<File
RelativePath=".\redis_hash.cpp">
</File>
</Filter>
<Filter
Name="Í·Îļþ"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
<File
RelativePath=".\stdafx.h">
</File>
</Filter>
<Filter
Name="×ÊÔ´Îļþ"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
</Filter>
<File
RelativePath=".\ReadMe.txt">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,409 @@
<?xml version="1.0" encoding="gb2312"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="redis_hash"
ProjectGUID="{2DABFAD1-114B-4F96-9185-DC0C56A3662D}"
Keyword="Win32Proj"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\include;..\..\..\..\lib_acl\include"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="ws2_32.lib"
OutputFile="$(OutDir)/redis_hash.exe"
LinkIncremental="2"
AdditionalLibraryDirectories="..\..\..\..\lib\win32;..\..\..\..\dist\lib\win32"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(OutDir)/redis_hash.pdb"
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\..\..\include;..\..\..\..\lib_acl\include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="0"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="ws2_32.lib wsock32.lib"
OutputFile="$(OutDir)/redis_hash.exe"
LinkIncremental="1"
AdditionalLibraryDirectories="..\..\..\..\lib\win32;..\..\..\..\dist\lib\win32"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="DebugDll|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\include;..\..\..\..\lib_acl\include"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;VC2003;ACL_CPP_DLL;ACL_DLL"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="ws2_32.lib"
OutputFile="$(OutDir)/redis_hash.exe"
LinkIncremental="2"
AdditionalLibraryDirectories="..\..\..\..\lib\win32"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(OutDir)/redis_hash.pdb"
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Releasedll|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\include;..\..\..\..\lib_acl\include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;VC2003;ACL_CPP_DLL;ACL_DLL"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="2"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="ws2_32.lib"
OutputFile="$(OutDir)/redis_hash.exe"
LinkIncremental="2"
AdditionalLibraryDirectories="..\..\..\..\lib\win32"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(OutDir)/redis_hash.pdb"
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Ô´Îļþ"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\stdafx.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="DebugDll|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Releasedll|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\redis_hash.cpp"
>
</File>
</Filter>
<Filter
Name="Í·Îļþ"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\stdafx.h"
>
</File>
</Filter>
<Filter
Name="×ÊÔ´Îļþ"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
<File
RelativePath=".\ReadMe.txt"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,197 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="DebugDll|Win32">
<Configuration>DebugDll</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Releasedll|Win32">
<Configuration>Releasedll</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{2DABFAD1-114B-4F96-9185-DC0C56A3662D}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Releasedll|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugDll|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Releasedll|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='DebugDll|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Debug\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Debug\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Release\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Release\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='DebugDll|Win32'">$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='DebugDll|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='DebugDll|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Releasedll|Win32'">$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Releasedll|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Releasedll|Win32'">true</LinkIncremental>
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='DebugDll|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='DebugDll|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='DebugDll|Win32'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Releasedll|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Releasedll|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Releasedll|Win32'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\..\include;..\..\..\..\lib_acl\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>lib_acl_vc2010d.lib;lib_acl_cpp_vc2010d.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)redis_hash.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\..\lib\win32;..\..\..\..\dist\lib\win32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)redis_hash.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
<IgnoreSpecificDefaultLibraries>
</IgnoreSpecificDefaultLibraries>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>..\..\..\include;..\..\..\..\lib_acl\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>ws2_32.lib;wsock32.lib;lib_acl_vc2010.lib;lib_acl_cpp_vc2010.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)redis_hash.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib;..\..\..\..\dist\lib\win32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
<IgnoreSpecificDefaultLibraries>
</IgnoreSpecificDefaultLibraries>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugDll|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\..\include;..\..\..\..\lib_acl\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;ACL_CPP_DLL;ACL_DLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>lib_acl_d.lib;lib_acl_cpp_d.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)redis_hash.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib;..\..\..\..\dist\lib\win32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)redis_hash.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Releasedll|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\..\include;..\..\..\..\lib_acl\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;ACL_CPP_DLL;ACL_DLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>lib_acl.lib;lib_acl_cpp.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)redis_hash.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib;..\..\..\..\dist\lib\win32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)redis_hash.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='DebugDll|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Releasedll|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="redis_hash.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h" />
</ItemGroup>
<ItemGroup>
<None Include="ReadMe.txt" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,202 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="DebugDll|Win32">
<Configuration>DebugDll</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Releasedll|Win32">
<Configuration>Releasedll</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{631B5BC6-1FD8-44C8-98C2-6003A0F01750}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<ProjectName>redis_hash</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Releasedll|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugDll|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Releasedll|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='DebugDll|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Debug\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Debug\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Release\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Release\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='DebugDll|Win32'">$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='DebugDll|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='DebugDll|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Releasedll|Win32'">$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Releasedll|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Releasedll|Win32'">true</LinkIncremental>
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='DebugDll|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='DebugDll|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='DebugDll|Win32'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Releasedll|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Releasedll|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Releasedll|Win32'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\..\include;..\..\..\..\lib_acl\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>lib_acl_vc2012d.lib;lib_acl_cpp_vc2012d.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)redis_hash.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\..\lib\win32;..\..\..\..\dist\lib\win32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)redis_hash.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
<IgnoreSpecificDefaultLibraries>
</IgnoreSpecificDefaultLibraries>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>..\..\..\include;..\..\..\..\lib_acl\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>ws2_32.lib;wsock32.lib;lib_acl_vc2012.lib;lib_acl_cpp_vc2012.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)redis_hash.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib;..\..\..\..\dist\lib\win32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
<IgnoreSpecificDefaultLibraries>
</IgnoreSpecificDefaultLibraries>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugDll|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\..\include;..\..\..\..\lib_acl\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;ACL_CPP_DLL;ACL_DLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>lib_acl_d.lib;lib_acl_cpp_d.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)redis_hash.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib;..\..\..\..\dist\lib\win32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)redis_hash.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Releasedll|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\..\include;..\..\..\..\lib_acl\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;ACL_CPP_DLL;ACL_DLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>lib_acl.lib;lib_acl_cpp.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)redis_hash.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib;..\..\..\..\dist\lib\win32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)redis_hash.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='DebugDll|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Releasedll|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="redis_hash.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h" />
</ItemGroup>
<ItemGroup>
<None Include="ReadMe.txt" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,8 @@
// stdafx.cpp : 只包括标准包含文件的源文件
// xml.pch 将成为预编译头
// stdafx.obj 将包含预编译类型信息
#include "stdafx.h"
// TODO: 在 STDAFX.H 中
//引用任何所需的附加头文件,而不是在此文件中引用

View File

@ -0,0 +1,14 @@
// stdafx.h : 标准系统包含文件的包含文件,
// 或是常用但不常更改的项目特定的包含文件
//
#pragma once
//
//#include <iostream>
//#include <tchar.h>
// TODO: 在此处引用程序要求的附加头文件
#include "acl_cpp/lib_acl.hpp"
#include "lib_acl.h"

View File

@ -0,0 +1,3 @@
#!/bin/sh
valgrind --tool=memcheck --leak-check=yes -v ./redis_hash -s 127.0.0.1:6379 -a all -n 10

View File

@ -0,0 +1,3 @@
base_path = ../../..
PROG = redis_key
include ../../Makefile.in

Binary file not shown.

View File

@ -15,7 +15,8 @@ static void test_del(acl::redis_key& option, int n)
printf("del key: %s error\r\n", key.c_str());
break;
}
option.get_client().reset();
else if (i < 10)
printf("del ok, key: %s\r\n", key.c_str());
}
}
@ -31,23 +32,27 @@ static void test_expire(acl::redis_key& option, int n)
printf("expire key: %s error\r\n", key.c_str());
break;
}
option.get_client().reset();
else if (i < 10)
printf("expire ok, key: %s\r\n", key.c_str());
}
}
static void test_ttl(acl::redis_key& option, int n)
{
acl::string key;
int ttl;
for (int i = 0; i < n; i++)
{
key.format("%s_%d", __keypre.c_str(), i);
if (option.ttl(key.c_str()) < 0)
if ((ttl = option.ttl(key.c_str())) < 0)
{
printf("get ttl key: %s error\r\n", key.c_str());
break;
}
option.get_client().reset();
else if (i < 10)
printf("ttl ok, key: %s, ttl: %d\r\n",
key.c_str(), ttl);
}
}
@ -60,7 +65,8 @@ static void test_exists(acl::redis_key& option, int n)
key.format("%s_%d", __keypre.c_str(), i);
if (option.exists(key.c_str()) == false)
printf("no exists key: %s\r\n", key.c_str());
option.get_client().reset();
else
printf("exists key: %s\r\n", key.c_str());
}
}
@ -77,7 +83,9 @@ static void test_type(acl::redis_key& option, int n)
printf("unknown type key: %s\r\n", key.c_str());
break;
}
option.get_client().reset();
else
printf("type ok, key: %s, ret: %d\r\n",
key.c_str(), ret);
}
}
@ -124,6 +132,7 @@ int main(int argc, char* argv[])
}
}
acl::acl_cpp_init();
acl::redis_client client(addr.c_str(), conn_timeout, rw_timeout);
acl::redis_key option(client);
@ -137,8 +146,20 @@ int main(int argc, char* argv[])
test_exists(option, n);
else if (cmd == "type")
test_type(option, n);
else if (cmd == "all")
{
test_expire(option, n);
test_ttl(option, n);
test_exists(option, n);
test_type(option, n);
test_del(option, n);
}
else
printf("unknown cmd: %s\r\n", cmd.c_str());
#ifdef WIN32
printf("enter any key to exit\r\n");
getchar();
#endif
return 0;
}

View File

@ -0,0 +1,3 @@
#!/bin/sh
valgrind --tool=memcheck --leak-check=yes -v ./redis_key -s 127.0.0.1:6379 -a all -n 10

View File

@ -0,0 +1,3 @@
base_path = ../../..
PROG = redis_string
include ../../Makefile.in

Binary file not shown.

View File

@ -19,7 +19,6 @@ static void test_set(acl::redis_string& option, int n)
}
else if (i < 10)
printf("set key: %s ok\r\n", key.c_str());
//option.get_client().reset();
}
}
@ -38,7 +37,6 @@ static void test_setex(acl::redis_string& option, int n, int ttl)
}
else if (i < 10)
printf("setex key: %s, ttl: %d\r\n", key.c_str(), ttl);
// option.get_client().reset();
}
}
@ -60,7 +58,6 @@ static void test_setnx(acl::redis_string& option, int n)
}
printf("%s: ret: %d, key: %s\r\n", __FUNCTION__, ret,
key.c_str());
// option.get_client().reset();
}
}
@ -79,7 +76,6 @@ static void test_append(acl::redis_string& option, int n)
printf("append key: %s\r\n", key.c_str());
break;
}
// option.get_client().reset();
}
}
@ -103,7 +99,6 @@ static void test_get(acl::redis_string& option, int n)
printf("key: %s, value: %s, len: %d\r\n",
key.c_str(), value.c_str(),
(int) value.length());
// option.get_client().reset();
}
}
@ -126,7 +121,6 @@ static void test_getset(acl::redis_string& option, int n)
else if (i < 10)
printf("getset: key: %s, old value: %s\r\n",
key.c_str(), result.c_str());
// option.get_client().reset();
}
}
@ -146,7 +140,6 @@ static void test_strlen(acl::redis_string& option, int n)
else if (i < 10)
printf("key: %s's value's length: %d\r\n",
key.c_str(), ret);
// option.get_client().reset();
}
}
@ -182,7 +175,6 @@ static void test_mset(acl::redis_string& option, int n)
key2.c_str(), val2.c_str(),
key3.c_str(), val3.c_str());
}
// option.get_client().reset();
objs.clear();
}
}
@ -191,6 +183,49 @@ static void test_mget(acl::redis_string& option, int n)
{
acl::string key1, key2, key3;
std::vector<acl::string> result;
const char* keys[3];
for (int i = 0; i < n; i++)
{
key1.format("key1_%s_%d", __keypre.c_str(), i);
key2.format("key2_%s_%d", __keypre.c_str(), i);
key3.format("key3_%s_%d", __keypre.c_str(), i);
keys[0] = key1.c_str();
keys[1] = key2.c_str();
keys[2] = key3.c_str();
result.clear();
if (option.mget(keys, 3, &result) == false)
{
printf("mset error\r\n");
break;
}
else if (i >= 10)
continue;
size_t size = option.mget_size();
printf("size: %lu\r\n", (unsigned long) size);
size_t j;
for (j = 0; j < size; j++)
{
const char* val = option.mget_value(j);
printf("mget ok, %s=%s\r\n",
keys[j], val ? val : "null");
}
std::vector<acl::string>::const_iterator it= result.begin();
for (j = 0; it != result.end(); ++it, j++)
printf("mget %s=%s\r\n", keys[j], (*it).c_str());
}
}
static void test_msetnx(acl::redis_string& option, int n)
{
acl::string key1, key2, key3;
acl::string val1, val2, val3;
std::map<acl::string, acl::string> objs;
int ret;
for (int i = 0; i < n; i++)
{
@ -198,34 +233,318 @@ static void test_mget(acl::redis_string& option, int n)
key2.format("key2_%s_%d", __keypre.c_str(), i);
key3.format("key3_%s_%d", __keypre.c_str(), i);
result.clear();
if (option.mget(&result, key1.c_str(), key2.c_str(),
key3.c_str(), NULL) == false)
val1.format("val1_%s", key1.c_str());
val2.format("val2_%s", key2.c_str());
val3.format("val3_%s", key3.c_str());
objs[key1] = val1;
objs[key2] = val2;
objs[key3] = val3;
ret = option.msetnx(objs);
if (ret < 0)
{
printf("mset error\r\n");
break;
}
else if (i < 10)
{
size_t size = option.mget_size();
printf("size: %lu\r\n", (unsigned long) size);
printf("key1: %s\r\n", key1.c_str());
printf("key2: %s\r\n", key2.c_str());
printf("key3: %s\r\n", key3.c_str());
for (size_t j = 0; j < size; j++)
{
const char* val = option.mget_value(j);
printf("mget ok, %s\r\n", val ? val : "null");
}
std::vector<acl::string>::const_iterator it;
for (it = result.begin(); it != result.end(); ++it)
printf("mget %s\r\n", (*it).c_str());
printf("msetnx ret: %d, %s=%s, %s=%s, %s=%s\r\n", ret,
key1.c_str(), val1.c_str(),
key2.c_str(), val2.c_str(),
key3.c_str(), val3.c_str());
}
// option.get_client().reset();
objs.clear();
}
}
static void test_setrange(acl::redis_string& option, int n)
{
acl::string key, value;
unsigned int off = 5;
int ret;
for (int i = 0; i < n; i++)
{
key.format("%s_%d", __keypre.c_str(), i);
value.format("range_value_%s", key.c_str());
ret = option.setrange(key.c_str(), off, value.c_str());
if (ret < 0)
{
printf("setrange error, key: %s, off: %u, value: %s\r\n",
key.c_str(), off, value.c_str());
break;
}
else if (i < 10)
printf("setrange ok, key: %s, off: %u, value: %s\r\n",
key.c_str(), off, value.c_str());
}
}
static void test_getrange(acl::redis_string& option, int n)
{
acl::string key, value;
int start = 5, end = 10;
for (int i = 0; i < n; i++)
{
key.format("%s_%d", __keypre.c_str(), i);
value.clear();
if (option.getrange(key, start, end, value) == false)
{
printf("getrange error, key: %s, start: %d, end: %d\r\n",
key.c_str(), start, end);
break;
}
else if (i >= 10)
continue;
printf("getrange ok, key: %s, start: %d, end: %d, value: %s\r\n",
key.c_str(), start, end, value.c_str());
}
}
static void test_setbit(acl::redis_string& option, int n)
{
acl::string key;
unsigned off = 5;
for (int i = 0; i < n; i++)
{
key.format("bit_%s_%d", __keypre.c_str(), i);
if (option.setbit(key.c_str(), off, 1) == false)
{
printf("setbit error, key: %s, off: %u\r\n",
key.c_str(), off);
break;
}
else if (i >= 10)
continue;
printf("setbit ok, key: %s, off: %d\r\n", key.c_str(), off);
}
}
static void test_getbit(acl::redis_string& option, int n)
{
acl::string key;
unsigned off = 5;
int bit;
for (int i = 0; i < n; i++)
{
key.format("bit_%s_%d", __keypre.c_str(), i);
if (option.getbit(key.c_str(), off, bit) == false)
{
printf("getbit error, key: %s, off: %u\r\n",
key.c_str(), off);
break;
}
else if (i >= 10)
continue;
printf("getbit ok, key: %s, off: %d, bit: %d\r\n",
key.c_str(), off, bit);
}
}
static void test_bitcount(acl::redis_string& option, int n)
{
acl::string key;
int ret;
for (int i = 0; i < n; i++)
{
key.format("bit_%s_%d", __keypre.c_str(), i);
ret = option.bitcount(key.c_str());
if (ret < 0)
{
printf("bitcount error, key: %s\r\n", key.c_str());
break;
}
else if (i < 10)
printf("bitcount ok, key: %s, ret: %d\r\n",
key.c_str(), ret);
}
}
static void test_bitop_and(acl::redis_string& option, int n)
{
const char* keys[3];
acl::string key, key1, key2, key3;
int ret;
for (int i = 0; i < n; i++)
{
key.format("bit_%s_%d", __keypre.c_str(), i);
key1.format("bit_%s_%d", __keypre.c_str(), i % 1);
key2.format("bit_%s_%d", __keypre.c_str(), i % 2);
key3.format("bit_%s_%d", __keypre.c_str(), i % 3);
keys[0] = key1.c_str();
keys[1] = key2.c_str();
keys[2] = key3.c_str();
ret = option.bitop_and(key.c_str(), keys, 3);
if (ret < 0)
{
printf("bitop_and error, key: %s\r\n", key.c_str());
break;
}
else if (i < 10)
printf("bitop_and ok, key: %s, bits: %u\n",
key.c_str(), ret);
}
}
static void test_bitop_or(acl::redis_string& option, int n)
{
const char* keys[3];
acl::string key, key1, key2, key3;
int ret;
for (int i = 0; i < n; i++)
{
key.format("bit_%s_%d", __keypre.c_str(), i);
key1.format("bit_%s_%d", __keypre.c_str(), i % 1);
key2.format("bit_%s_%d", __keypre.c_str(), i % 2);
key3.format("bit_%s_%d", __keypre.c_str(), i % 3);
keys[0] = key1.c_str();
keys[1] = key2.c_str();
keys[2] = key3.c_str();
ret = option.bitop_or(key.c_str(), keys, 3);
if (ret < 0)
{
printf("bitop_or error, key: %s\r\n", key.c_str());
break;
}
else if (i < 10)
printf("bitop_or ok, key: %s, bits: %u\n",
key.c_str(), ret);
}
}
static void test_bitop_xor(acl::redis_string& option, int n)
{
const char* keys[3];
acl::string key, key1, key2, key3;
int ret;
for (int i = 0; i < n; i++)
{
key.format("bit_%s_%d", __keypre.c_str(), i);
key1.format("bit_%s_%d", __keypre.c_str(), i % 1);
key2.format("bit_%s_%d", __keypre.c_str(), i % 2);
key3.format("bit_%s_%d", __keypre.c_str(), i % 3);
keys[0] = key1.c_str();
keys[1] = key2.c_str();
keys[2] = key3.c_str();
ret = option.bitop_xor(key.c_str(), keys, 3);
if (ret < 0)
{
printf("bitop_xor error, key: %s\r\n", key.c_str());
break;
}
else if (i < 10)
printf("bitop_xor ok, key: %s, bits: %u\n",
key.c_str(), ret);
}
}
static void test_incr(acl::redis_string& option, int n)
{
acl::string key;
long long int result;
for (int i = 0; i < n; i++)
{
key.format("incr_%s_%d", __keypre.c_str(), i);
if (option.incr(key.c_str(), &result) == false)
{
printf("incr error, key: %s\r\n", key.c_str());
break;
}
else if (i < 10)
printf("incr ok, key: %s, result: %lld\r\n",
key.c_str(), result);
}
}
static void test_incrby(acl::redis_string& option, int n)
{
acl::string key;
long long int result;
for (int i = 0; i < n; i++)
{
key.format("incr_%s_%d", __keypre.c_str(), i);
if (option.incrby(key.c_str(), 10, &result) == false)
{
printf("incrby error, key: %s\r\n", key.c_str());
break;
}
else if (i < 10)
printf("incrby ok, key: %s, result: %lld\r\n",
key.c_str(), result);
}
}
static void test_incrbyfloat(acl::redis_string& option, int n)
{
acl::string key;
double result;
for (int i = 0; i < n; i++)
{
key.format("incrbyfloat_%s_%d", __keypre.c_str(), i);
if (option.incrbyfloat(key.c_str(), 8.8, &result) == false)
{
printf("incrbyfloat error, key: %s\r\n", key.c_str());
break;
}
else if (i < 10)
printf("incrbyfloat ok, key: %s, result: %.2f\r\n",
key.c_str(), result);
}
}
static void test_decr(acl::redis_string& option, int n)
{
acl::string key;
long long int result;
for (int i = 0; i < n; i++)
{
key.format("incr_%s_%d", __keypre.c_str(), i);
if (option.decr(key.c_str(), &result) == false)
{
printf("decr error, key: %s\r\n", key.c_str());
break;
}
else if (i < 10)
printf("decr ok, key: %s, result: %lld\r\n",
key.c_str(), result);
}
}
static void test_decrby(acl::redis_string& option, int n)
{
acl::string key;
long long int result;
for (int i = 0; i < n; i++)
{
key.format("incr_%s_%d", __keypre.c_str(), i);
if (option.decrby(key.c_str(), 10, &result) == false)
{
printf("decrby error, key: %s\r\n", key.c_str());
break;
}
else if (i < 10)
printf("decrby ok, key: %s, result: %lld\r\n",
key.c_str(), result);
}
}
static void usage(const char* procname)
@ -298,7 +617,6 @@ int main(int argc, char* argv[])
test_mset(option, n);
else if (cmd == "mget")
test_mget(option, n);
/*
else if (cmd == "msetnx")
test_msetnx(option, n);
else if (cmd == "setrange")
@ -327,7 +645,32 @@ int main(int argc, char* argv[])
test_decr(option, n);
else if (cmd == "decrby")
test_decrby(option, n);
*/
else if (cmd == "all")
{
test_set(option, n);
test_setex(option, n, ttl);
test_setnx(option, n);
test_append(option, n);
test_get(option, n);
test_getset(option, n);
test_strlen(option, n);
test_mset(option, n);
test_mget(option, n);
test_msetnx(option, n);
test_setrange(option, n);
test_getrange(option, n);
test_setbit(option, n);
test_getbit(option, n);
test_bitcount(option, n);
test_bitop_and(option, n);
test_bitop_or(option, n);
test_bitop_xor(option, n);
test_incr(option, n);
test_incrby(option, n);
test_incrbyfloat(option, n);
test_decr(option, n);
test_decrby(option, n);
}
else
printf("unknown cmd: %s\r\n", cmd.c_str());

View File

@ -6,5 +6,23 @@ valgrind --tool=memcheck --leak-check=yes -v ./redis_string -s 127.0.0.1:6379 -a
valgrind --tool=memcheck --leak-check=yes -v ./redis_string -s 127.0.0.1:6379 -a append -n 10
valgrind --tool=memcheck --leak-check=yes -v ./redis_string -s 127.0.0.1:6379 -a get -n 10
valgrind --tool=memcheck --leak-check=yes -v ./redis_string -s 127.0.0.1:6379 -a getset -n 10
valgrind --tool=memcheck --leak-check=yes -v ./redis_string -s 127.0.0.1:6379 -a strlen -n 10
valgrind --tool=memcheck --leak-check=yes -v ./redis_string -s 127.0.0.1:6379 -a mset -n 10
valgrind --tool=memcheck --leak-check=yes -v ./redis_string -s 127.0.0.1:6379 -a mget -n 10
valgrind --tool=memcheck --leak-check=yes -v ./redis_string -s 127.0.0.1:6379 -a mget -n 10
valgrind --tool=memcheck --leak-check=yes -v ./redis_string -s 127.0.0.1:6379 -a mgetnx -n 10
valgrind --tool=memcheck --leak-check=yes -v ./redis_string -s 127.0.0.1:6379 -a setrange -n 10
valgrind --tool=memcheck --leak-check=yes -v ./redis_string -s 127.0.0.1:6379 -a getrange -n 10
valgrind --tool=memcheck --leak-check=yes -v ./redis_string -s 127.0.0.1:6379 -a setbit -n 10
valgrind --tool=memcheck --leak-check=yes -v ./redis_string -s 127.0.0.1:6379 -a getbit -n 10
valgrind --tool=memcheck --leak-check=yes -v ./redis_string -s 127.0.0.1:6379 -a bitcount -n 10
valgrind --tool=memcheck --leak-check=yes -v ./redis_string -s 127.0.0.1:6379 -a bitop_and -n 10
valgrind --tool=memcheck --leak-check=yes -v ./redis_string -s 127.0.0.1:6379 -a bitop_or -n 10
valgrind --tool=memcheck --leak-check=yes -v ./redis_string -s 127.0.0.1:6379 -a bitop_xor -n 10
valgrind --tool=memcheck --leak-check=yes -v ./redis_string -s 127.0.0.1:6379 -a incr -n 10
valgrind --tool=memcheck --leak-check=yes -v ./redis_string -s 127.0.0.1:6379 -a incrby -n 10
valgrind --tool=memcheck --leak-check=yes -v ./redis_string -s 127.0.0.1:6379 -a incrbyfloat -n 10
valgrind --tool=memcheck --leak-check=yes -v ./redis_string -s 127.0.0.1:6379 -a decr -n 10
valgrind --tool=memcheck --leak-check=yes -v ./redis_string -s 127.0.0.1:6379 -a decrby -n 10
valgrind --tool=memcheck --leak-check=yes -v ./redis_string -s 127.0.0.1:6379 -a all -n 10

View File

@ -0,0 +1,3 @@
base_path = ../../..
include ../../Makefile.in
PROG = socket_client

View File

@ -0,0 +1,92 @@
#include "acl_cpp/lib_acl.hpp"
#include "lib_acl.h"
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char* argv[])
{
acl::socket_stream client;
acl::string addr = "127.0.0.1:9001";
acl::string a;
printf("hello\n");
string a;
if (argc >= 2)
addr = argv[1];
if (client.open(addr, 0, 0) == false)
{
printf("open %s error\n", addr.c_str());
return 1;
}
else
printf("open %s ok\r\n", addr.c_str());
// 探测连接是否正常
if (client.alive())
printf("first check: ok, status: %s\r\n", acl::last_serror());
else
printf("first check: disconnected, status: %s\r\n",
acl::last_serror());
// 读服务器端写入的一行数据
acl::string buf;
if (client.gets(buf) == false)
{
printf("gets error, status: %s\r\n", acl::last_serror());
return 1;
}
printf("gets: %s\r\n", buf.c_str());
// 探测连接是否正常
if (client.alive())
printf("second check: ok, status: %s\r\n", acl::last_serror());
else
printf("second check: disconnected, status: %s\r\n",
acl::last_serror());
acl::string req = "echo1\r\n"
"echo2\r\n"
"echo3\r\n"
"read_delay1\r\n"
"read_delay2\r\n"
"read_delay3\r\n"
"read_delay4\r\n"
"read_delay5\r\n"
"quit\r\n";
int n = 10;
printf("sleep %d second\r\n", n);
// 休息一下,以保证服务器肯定已经关闭了连接
for (int i = 0; i < n; i++)
{
sleep(1);
putchar('.');
fflush(stdout);
}
printf("\r\n");
// 检查第一次写入时 write 是否返回失败
if ((n = client.write(req.c_str(), req.length())) < 0)
{
printf("first write error, status: %s\n", acl::last_serror());
return 1;
}
else
printf("first write ok, ret: %d, status: %s\r\n",
n, acl::last_serror());
// 检查第二次写入时 write 是否返回失败
if ((n = client.write(req.c_str(), req.length())) < 0)
{
printf("second write error, status: %s\n", acl::last_serror());
return 1;
}
else
printf("second write ok: ret: %d, status: %s\r\n",
n, acl::last_serror());
return (0);
}

View File

@ -0,0 +1,6 @@
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/
!_TAG_PROGRAM_NAME Exuberant Ctags //
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
!_TAG_PROGRAM_VERSION 5.9~svn20110310 //

View File

@ -477,6 +477,13 @@ unsigned long long beanstalk::reserve(string& buf, int timeout /* = -1 */)
logger_error("'%s' error", cmdline.c_str());
return 0;
}
if (strcasecmp(tokens->argv[0], "TIMED_OUT") == 0
|| strcasecmp(tokens->argv[0], "DEADLINE_SOON") == 0)
{
ACL_SAFE_STRNCPY(errbuf_, tokens->argv[0], sizeof(errbuf_));
acl_argv_free(tokens);
return 0;
}
if (tokens->argc < 3 || strcasecmp(tokens->argv[0], "RESERVED"))
{
logger_error("reserve failed: %s", tokens->argv[0]);

View File

@ -33,8 +33,10 @@ redis_client::~redis_client()
if (result_)
result_->reset();
delete pool_;
acl_myfree(argv_);
acl_myfree(argv_lens_);
if (argv_ != NULL)
acl_myfree(argv_);
if (argv_lens_ != NULL)
acl_myfree(argv_lens_);
}
void redis_client::reset()
@ -54,8 +56,17 @@ void redis_client::argv_space(size_t n)
if (argv_size_ >= n)
return;
argv_size_ = n;
argv_ = (const char**) acl_mymalloc(n * sizeof(char*));
argv_lens_ = (size_t*) acl_mymalloc(n * sizeof(size_t));
if (argv_ == NULL)
{
argv_ = (const char**) acl_mymalloc(n * sizeof(char*));
argv_lens_ = (size_t*) acl_mymalloc(n * sizeof(size_t));
}
else
{
argv_ = (const char**) acl_myrealloc(argv_, n * sizeof(char*));
argv_lens_ = (size_t*) acl_myrealloc(argv_lens_,
n * sizeof(size_t));
}
}
bool redis_client::open()
@ -796,7 +807,7 @@ const string& redis_client::build(const char* cmd, const char* key,
argc_ = 1 + argc * 2;
if (key != NULL)
argc++;
argc_++;
argv_space(argc_);
size_t i = 0;
@ -833,7 +844,7 @@ const string& redis_client::build(const char* cmd, const char* key,
argc_ = 1 + argc * 2;
if (key != NULL)
argc++;
argc_++;
argv_space(argc_);
size_t i = 0;
@ -874,7 +885,7 @@ const string& redis_client::build(const char* cmd, const char* key,
argc_ = 1 + argc * 2;
if (key != NULL)
argc++;
argc_++;
argv_space(argc_);
size_t i = 0;

View File

@ -73,60 +73,103 @@ bool redis_hash::hmset(const string& req)
/////////////////////////////////////////////////////////////////////////////
bool redis_hash::hmget(const char* key, const std::vector<string>& names)
bool redis_hash::hmget(const char* key, const std::vector<string>& names,
std::vector<string>* result /* = NULL */)
{
const string& req = conn_.build("HMGET", key, names);
return hmget(req);
return hmget(req, result);
}
bool redis_hash::hmget(const char* key, const std::vector<char*>& names)
bool redis_hash::hmget(const char* key, const std::vector<char*>& names,
std::vector<string>* result /* = NULL */)
{
const string& req = conn_.build("HMGET", key, names);
return hmget(req);
return hmget(req, result);
}
bool redis_hash::hmget(const char* key, const std::vector<const char*>& names)
bool redis_hash::hmget(const char* key, const std::vector<const char*>& names,
std::vector<string>* result /* = NULL */)
{
const string& req = conn_.build("HMGET", key, names);
return hmget(req);
return hmget(req, result);
}
bool redis_hash::hmget(const char* key, const std::vector<int>& names)
bool redis_hash::hmget(const char* key, const std::vector<int>& names,
std::vector<string>* result /* = NULL */)
{
const string& req = conn_.build("HMGET", key, names);
return hmget(req);
return hmget(req, result);
}
bool redis_hash::hmget(const char* key, const char* names[], size_t argc)
bool redis_hash::hmget(const char* key, const char* names[], size_t argc,
std::vector<string>* result /* = NULL */)
{
const string& req = conn_.build("HMGET", key, names, argc);
return hmget(req);
return hmget(req, result);
}
bool redis_hash::hmget(const char* key, const int names[], size_t argc)
bool redis_hash::hmget(const char* key, const int names[], size_t argc,
std::vector<string>* result /* = NULL */)
{
const string& req = conn_.build("HMGET", key, names, argc);
return hmget(req);
return hmget(req, result);
}
bool redis_hash::hmget(const char* key, const char* names[],
const size_t lens[], size_t argc)
const size_t lens[], size_t argc, std::vector<string>* result /* = NULL */)
{
const string& req = conn_.build("HMGET", key, names, lens, argc);
return hmget(req);
return hmget(req, result);
}
bool redis_hash::hmget(const string& req)
bool redis_hash::hmget(const string& req, std::vector<string>* result /* = NULL */)
{
result_ = conn_.run(req);
if (result_ == NULL)
return false;
if (result_->get_type() != REDIS_RESULT_ARRAY)
return false;
if (result == NULL)
return true;
size_t size = hmget_size();
const redis_result* rr;
size_t nslice, len;
const char* ptr;
string buf(4096);
for (size_t i = 0; i < size; i++)
{
rr = hmget_result(i);
if (rr == NULL || (nslice = rr->get_size()) == 0)
result->push_back("");
else if (nslice == 1)
{
ptr = rr->get(0, &len);
buf.copy(ptr, len);
result->push_back(buf);
}
else
{
buf.clear();
rr->argv_to_string(buf);
result->push_back(buf);
}
}
return true;
}
const char* redis_hash::hmget_result(size_t i, size_t* len /* = NULL */) const
const redis_result* redis_hash::hmget_result(size_t i) const
{
if (result_ == NULL)
return NULL;
if (result_->get_type() != REDIS_RESULT_ARRAY)
return NULL;
return result_->get_child(i);
}
const char* redis_hash::hmget_value(size_t i, size_t* len /* = NULL */) const
{
if (result_ == NULL)
return NULL;
@ -151,6 +194,15 @@ const char* redis_hash::hmget_result(size_t i, size_t* len /* = NULL */) const
return buf;
}
size_t redis_hash::hmget_size() const
{
if (result_ == NULL)
return 0;
if (result_->get_type() != REDIS_RESULT_ARRAY)
return 0;
return result_->get_size();
}
/////////////////////////////////////////////////////////////////////////////
int redis_hash::hset(const char* key, const char* name, const char* value)
@ -168,13 +220,15 @@ int redis_hash::hset(const char* key, const char* name, size_t name_len,
const char* value, size_t value_len)
{
const char* names[1];
names[0] = name;
size_t names_len[1];
names[0] = name;
names_len[0] = name_len;
const char* values[1];
values[0] = value;
size_t values_len[1];
values[0] = value;
values_len[0] = value_len;
const string& req = conn_.build("HSET", key, names, names_len,
@ -404,6 +458,7 @@ int redis_hash::hdel(const char* key, const char* first_name, ...)
{
const char* name;
std::vector<const char*> names;
names.push_back(first_name);
va_list ap;
va_start(ap, first_name);
while((name = va_arg(ap, const char*)) != NULL)
@ -481,7 +536,7 @@ bool redis_hash::hincrbyfloat(const char* key, const char* name,
(void) safe_snprintf(buf, sizeof(buf), "%f", inc);
const char* values[1];
values[0] = buf;
const string& req = conn_.build("HINCRBY", key, names, values, 1);
const string& req = conn_.build("HINCRBYFLOAT", key, names, values, 1);
result_ = conn_.run(req);
if (result_ == NULL)
return false;

View File

@ -186,7 +186,7 @@ bool redis_string::getset(const char* key, size_t key_len,
if (result_ == NULL)
return false;
if (result_->get_type() != REDIS_RESULT_STRING)
return NULL;
return false;
(void) result_->argv_to_string(buf);
return true;
}
@ -264,7 +264,7 @@ bool redis_string::getrange(const char* key, size_t key_len,
char start_buf[INT_LEN], end_buf[INT_LEN];
(void) safe_snprintf(start_buf, sizeof(start_buf), "%d", start);
names[1] = start_buf;
lens[2] = strlen(start_buf);
lens[1] = strlen(start_buf);
(void) safe_snprintf(end_buf, sizeof(end_buf), "%d", end);
names[2] = end_buf;
@ -330,7 +330,7 @@ bool redis_string::getbit(const char* key, size_t len, unsigned offset, int& bit
names[1] = buf4off;
lens[1] = strlen(buf4off);
const string& req = conn_.build("SETBIT", NULL, names, lens, 3);
const string& req = conn_.build("GETBIT", NULL, names, lens, 2);
result_ = conn_.run(req);
if (result_ == NULL)
return false;
@ -722,8 +722,8 @@ bool redis_string::mget(const string& req,
return true;
size_t size = mget_size();
string buf;
const redis_result* rr;
string buf(4096);
const redis_result* rr;
size_t nslice, len;
const char* ptr;
@ -840,16 +840,20 @@ bool redis_string::decrby(const char* key, long long int dec,
bool redis_string::incoper(const char* cmd, const char* key, long long int n,
long long int* result)
{
const char* keys[1];
const char* values[1];
size_t argc = 1;
const char* names[2];
keys[0] = key;
names[0] = key;
char buf[INT64_LEN];
(void) acl_i64toa(n, buf, sizeof(buf));
values[0] = buf;
if (n != 1)
{
(void) acl_i64toa(n, buf, sizeof(buf));
names[1] = buf;
argc++;
}
const string& req = conn_.build(cmd, NULL, keys, values, 1);
const string& req = conn_.build(cmd, NULL, names, argc);
result_ = conn_.run(req);
if (result_ == NULL)
return false;