poco::redis Array

poco::redis Array

Library: Redis

Package: Redis

Header: Poco/Redis/Array.h

It represents a redis Array. It has similar properties to that of an array object. It can store data with datatype string, bulk string, integers etc. We can also store arrays in the redis array. We can declare an empty array as well in which each element will have NULL value.

Member Functions -


Syntax:-    Array & add();

This function declare array with data type of elements as BulkString with values as NULL.

To add an element use the following syntax:-

template < typename T > Array & add(

    const T & arg


// for implementation const char*

Array & add(

    const char * s


// for implementation of a vector with strings.

Array & add(

    const std::vector < std::string > & strings


Now for iterating the array we can use iterator as shown below:-

const_iterator begin() const;

This points to the start of the array. To point the end of an array we have end(); as shown below:-

const_iterator end() const;

To get the element at a specific position in the array we can use the get() function.

template < typename T > T get(

    size_t pos

) const;

We need to make sure that we enter a valid position to avoid InvalidArgumentException exception. This three functions can return NullValuException if the array is empty i.e. NULL. Therefore to check if the array is empty we can us isNull() function that returns boolean value i.e either true if array is empty or false if not empty.

bool isNull() const;

To clear the elements of array we can use clear function which is as:-

void clear();

We have a function that returns the size of an array here which is similar to that in STL .

size_t size() const;

Size function also returns nullValueException if the array is empty.