--- parser3/src/classes/memcached.C 2012/06/05 07:56:48 1.5 +++ parser3/src/classes/memcached.C 2013/04/23 22:57:06 1.9 @@ -15,7 +15,7 @@ #include "pa_vbool.h" #include "pa_vmemcached.h" -volatile const char * IDENT_MEMCACHED_C="$Id: memcached.C,v 1.5 2012/06/05 07:56:48 moko Exp $"; +volatile const char * IDENT_MEMCACHED_C="$Id: memcached.C,v 1.9 2013/04/23 22:57:06 moko Exp $"; class MMemcached: public Methoded { public: // VStateless_class @@ -34,10 +34,14 @@ static void _open(Request& r, MethodPara if(HashStringValue* options=param_value.get_hash()){ String result; for(HashStringValue::Iterator i(*options); i; i.next()){ - result << (result.is_empty() ? "--" : " --") << i.key(); - const String& value=i.value()->as_string(); - if(!value.is_empty()) - result << "=" << value; + if(Value *b=i.value()->as("bool")){ + if(b->as_bool()) + result << (result.is_empty() ? "--" : " --") << i.key(); + } else { + const String& value=i.value()->as_string(); + if(!value.is_empty()) + result << (result.is_empty() ? "--" : " --") << i.key() << "=" << value; + } } self.open(result, ttl); } else { @@ -46,7 +50,7 @@ static void _open(Request& r, MethodPara } } -static void _flush(Request& r, MethodParams& params) { +static void _clear(Request& r, MethodParams& params) { VMemcached& self=GET_SELF(r, VMemcached); time_t ttl=(params.count()>0) ? params.as_int(0, "expiration must be int", r) : 0; @@ -96,10 +100,17 @@ static void _delete(Request& r, MethodPa self.remove(key); } +static void _release(Request& r, MethodParams& params) { + VMemcached& self=GET_SELF(r, VMemcached); + + self.quit(); +} + MMemcached::MMemcached() : Methoded("memcached") { add_native_method("open", Method::CT_DYNAMIC, _open, 1, 2); - add_native_method("flush", Method::CT_DYNAMIC, _flush, 0, 1); + add_native_method("clear", Method::CT_DYNAMIC, _clear, 0, 1); add_native_method("mget", Method::CT_DYNAMIC, _mget, 1, 1000); add_native_method("add", Method::CT_DYNAMIC, _add, 2, 2); add_native_method("delete", Method::CT_DYNAMIC, _delete, 1, 1); + add_native_method("release", Method::CT_DYNAMIC, _release, 0, 0); }