making the custom_flag bit customizable instead of fixed

master
Ray Slakinski 2010-11-22 20:05:37 -05:00
parent 5549b58553
commit b201a84ba1
2 changed files with 12 additions and 13 deletions

View File

@ -475,17 +475,17 @@ static PyObject *_PylibMC_RunSetCommandSingle(PylibMC_Client *self,
_PylibMC_SetCommand f, char *fname, PyObject *args,
PyObject *kwds) {
/* function called by the set/add/etc commands */
static char *kws[] = { "key", "val", "time", "use_custom_flag", "min_compress_len", NULL };
static char *kws[] = { "key", "val", "time", "custom_flag", "min_compress_len", NULL };
PyObject *key;
PyObject *value;
unsigned int time = 0; /* this will be turned into a time_t */
unsigned int use_custom_flag = 0;
unsigned int custom_flag = 0;
unsigned int min_compress = 0;
bool success = false;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "SO|III", kws,
&key, &value,
&time, &use_custom_flag, &min_compress)) {
&time, &custom_flag, &min_compress)) {
return NULL;
}
@ -505,7 +505,7 @@ static PyObject *_PylibMC_RunSetCommandSingle(PylibMC_Client *self,
success = _PylibMC_RunSetCommand(self, f, fname,
&serialized, 1,
use_custom_flag,
custom_flag,
min_compress);
cleanup:
@ -528,16 +528,16 @@ static PyObject *_PylibMC_RunSetCommandMulti(PylibMC_Client* self,
PyObject* key_prefix = NULL;
unsigned int time = 0;
unsigned int min_compress = 0;
unsigned int use_custom_flag = 0;
unsigned int custom_flag = 0;
PyObject * retval = NULL;
size_t idx = 0;
static char *kws[] = { "keys", "time", "key_prefix", "use_custom_flag", "min_compress_len", NULL };
static char *kws[] = { "keys", "time", "key_prefix", "custom_flag", "min_compress_len", NULL };
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!|ISII", kws,
&PyDict_Type, &keys,
&time, &key_prefix,
&use_custom_flag,
&custom_flag,
&min_compress)) {
return NULL;
}
@ -588,7 +588,7 @@ static PyObject *_PylibMC_RunSetCommandMulti(PylibMC_Client* self,
bool allsuccess = _PylibMC_RunSetCommand(self, f, fname,
serialized, nkeys,
use_custom_flag,
custom_flag,
min_compress);
if (PyErr_Occurred() != NULL) {
@ -815,7 +815,7 @@ static int _PylibMC_SerializeValue(PyObject* key_obj,
static bool _PylibMC_RunSetCommand(PylibMC_Client* self,
_PylibMC_SetCommand f, char *fname,
pylibmc_mset* msets, size_t nkeys,
size_t use_custom_flag,
size_t custom_flag,
size_t min_compress) {
memcached_st* mc = self->mc;
memcached_return rc = MEMCACHED_SUCCESS;
@ -832,8 +832,8 @@ static bool _PylibMC_RunSetCommand(PylibMC_Client* self,
size_t value_len = mset->value_len;
uint32_t flags = mset->flags;
if (use_custom_flag) {
flags |= PYLIBMC_FLAG_CUSTOM;
if (custom_flag) {
flags |= (1 << custom_flag);
}
#ifdef USE_ZLIB

View File

@ -62,7 +62,6 @@ typedef ssize_t Py_ssize_t;
#define PYLIBMC_FLAG_LONG (1 << 2)
/* Note: this is an addition! python-memcached doesn't handle bools. */
#define PYLIBMC_FLAG_BOOL (1 << 4)
#define PYLIBMC_FLAG_CUSTOM (1 << 5)
#define PYLIBMC_FLAG_TYPES (PYLIBMC_FLAG_PICKLE | PYLIBMC_FLAG_INTEGER | \
PYLIBMC_FLAG_LONG | PYLIBMC_FLAG_BOOL | PYLIBMC_FLAG_CUSTOM)
/* Modifier flags */
@ -279,7 +278,7 @@ static PyObject *_PylibMC_RunSetCommandMulti(PylibMC_Client* self,
static bool _PylibMC_RunSetCommand(PylibMC_Client* self,
_PylibMC_SetCommand f, char *fname,
pylibmc_mset* msets, size_t nkeys,
size_t use_custom_flag,
size_t custom_flag,
size_t min_compress);
static int _PylibMC_Deflate(char* value, size_t value_len,
char** result, size_t *result_len);