@@ -44,7 +44,7 @@ public function get($key, QueryOptions $queryOptions = null)
4444 if (!is_string ($ key ))
4545 {
4646 return [null , null , new Error ('error ' , sprintf (
47- '%s::getValue - Key expected to be string, %s seen. ' ,
47+ '%s::get - Key expected to be string, %s seen. ' ,
4848 get_class ($ this ),
4949 gettype ($ key )
5050 ))];
@@ -67,6 +67,51 @@ public function get($key, QueryOptions $queryOptions = null)
6767 return [new KVPair (reset ($ data )), $ qm , null ];
6868 }
6969
70+ /**
71+ * @param string $prefix
72+ * @param QueryOptions|null $queryOptions
73+ * @return array(
74+ * @type KVPair[]|null array of KVPair objects under specified prefix
75+ * @type QueryMeta|null query metadata
76+ * @type Error|null error, if any
77+ * )
78+ */
79+ public function getList ($ prefix , QueryOptions $ queryOptions = null )
80+ {
81+ if (!is_string ($ prefix ) || '' === $ prefix )
82+ {
83+ return [null , null , new Error ('error ' , sprintf (
84+ '%s::getList - Prefix expected to be empty or string, %s seen. ' ,
85+ get_class ($ this ),
86+ gettype ($ prefix )
87+ ))];
88+ }
89+
90+ $ r = new Request ('get ' , sprintf ('v1/kv/%s ' , rawurlencode ($ prefix )), $ this ->_Config );
91+ $ r ->setQueryOptions ($ queryOptions );
92+ $ r ->params ()->set ('recurse ' , '' );
93+
94+ list ($ duration , $ response , $ err ) = $ this ->requireOK ($ this ->doRequest ($ r ));
95+ $ qm = $ this ->buildQueryMeta ($ duration , $ response );
96+
97+ if (null !== $ err )
98+ return [null , $ qm , $ err ];
99+
100+ list ($ data , $ err ) = $ this ->decodeBody ($ response );
101+
102+ if (null !== $ err )
103+ return [null , $ qm , $ err ];
104+
105+ $ kvPairs = array ();
106+ foreach ($ data as $ v )
107+ {
108+ $ kvp = new KVPair ($ v );
109+ $ kvPairs [$ kvp ->getKey ()] = $ kvp ;
110+ }
111+
112+ return [$ kvPairs , $ qm , null ];
113+ }
114+
70115 /**
71116 * @param string $prefix Prefix to search for. Null returns all keys.
72117 * @param QueryOptions $queryOptions
@@ -81,7 +126,7 @@ public function keys($prefix = null, QueryOptions $queryOptions = null)
81126 if (null !== $ prefix && !is_string ($ prefix ))
82127 {
83128 return [null , null , new Error ('error ' , sprintf (
84- '%s::getKeys - Prefix expected to be empty or string, %s seen. ' ,
129+ '%s::keys - Prefix expected to be empty or string, %s seen. ' ,
85130 get_class ($ this ),
86131 gettype ($ prefix )
87132 ))];
0 commit comments