--- parser3/src/classes/memcached.C 2020/12/15 17:10:29 1.16 +++ parser3/src/classes/memcached.C 2026/10/13 23:16:35 1.22 @@ -1,7 +1,7 @@ /** @file Parser: memcached class. - Copyright (c) 2001-2020 Art. Lebedev Studio (http://www.artlebedev.com) + Copyright (c) 2001-2026 Art. Lebedev Studio (https://www.artlebedev.com) Authors: Ivan Poluyanov Artem Stepanov @@ -12,14 +12,15 @@ #include "pa_request.h" #include "pa_vstring.h" #include "pa_vtable.h" +#include "pa_varray.h" #include "pa_vbool.h" #include "pa_vmemcached.h" -volatile const char * IDENT_MEMCACHED_C="$Id: memcached.C,v 1.16 2020/12/15 17:10:29 moko Exp $"; +volatile const char * IDENT_MEMCACHED_C="$Id: memcached.C,v 1.22 2026/10/13 23:16:35 moko Exp $"; class MMemcached: public Methoded { public: // VStateless_class - Value* create_new_value(Pool&) { return new VMemcached(); } + Value* create_new_value(Pool& apool) { return new VMemcached(apool); } public: MMemcached(); }; @@ -37,7 +38,7 @@ static void _open(Request& r, MethodPara for(HashStringValue::Iterator i(*options); i; i.next()){ if(i.key() == "skip-connect"){ connect=!i.value()->as_bool(); - } else if(Value *b=i.value()->as("bool")){ + } else if(Value *b=dynamic_cast(i.value())){ if(b->as_bool()) result << (result.is_empty() ? "--" : " --") << i.key(); } else { @@ -62,31 +63,30 @@ static void _clear(Request& r, MethodPar static void _mget(Request& r, MethodParams& params) { VMemcached& self=GET_SELF(r, VMemcached); - Value& param=params.as_no_junction(0, PARAM_MUST_NOT_BE_CODE); - if(param.is_string()){ + ArrayString keys(params.count()); - ArrayString keys(params.count()); - - for(size_t i=0; icount()); - - for(size_t i=0; icount(); i++) { - keys+=table->get(i)->get(0); - } - - r.write(self.mget(keys)); + for(size_t i=0; icount(); j++) + keys+=table->get(j)->get(0); + } else if(VArray* array=dynamic_cast(¶m)){ + for(ArrayValue::Iterator j(array->array()); j; j.next()){ + if(Value* value=j.value()){ + const String* string=value->get_string(); + if(!string) + value->bark("array element is '%s', it does not have string value"); + keys+=string; + } + } + } else + throw Exception("memcached", 0, "key must be string, table or array of strings"); } + + r.write(self.mget(keys)); } static void _add(Request& r, MethodParams& params) {