How to improve your website’s performance

Redis is an open source, in-memory data structure store, used as a database, cache and message broker. It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries and more.

Redis has built-in replication, transactions, different levels of on-disk persistence, and provides high availability via Redis Sentinel.

You can run atomic operations on Redis data types, like appending to a string; incrementing the value in a hash; pushing an element to a list; computing set intersection, union and difference; or getting the member with highest ranking in a sorted set.

Performance is critical for websites especially in ecommerce applications. Using Redis and POCO C++ in combination with a relational database management system (RDBMS) like MySQL, PostgreSQL or Microsoft’s SQL server by caching frequently used queries can vastly improve response times.

In order to achieve its outstanding performance, Redis works with an in memory dataset. Depending on your use case, you can persist your data either by periodically dumping the dataset to disk, or by appending each command to a log. Persistence can be optionally disabled, if you just need a feature-rich, networked, in memory cache.

POCO C++ Libraries The POrtable COmponents (POCO) C++ Libraries are a set of powerful open source, cross-platform, class libraries for developing network-centric, portable applications in the C++ programming language. Written in efficient, modern, 100% ANSI/ISO Standard C+, the POCO libraries include an HTTP server and cover core functionality such as:

  • threads
  • file system access
  • streams
  • sockets
  • network communications protocols (HTTP, FTP, SMTP, etc.)
  • JSON & XML parsers
  • database access

The modular and efficient design and implementation of the POCO libraries makes them well suited for embedded system development, as well.

Because Redis and the POCO libraries' functionality is performance focused, using Redis with your POCO C++ application can dramatically transform the speed in which data is returned to your customers. Which can be the difference between having a customer or having a customer look elsewhere for their purchase.

This perfomance is especially important today, with the majority of clients accessing your site via mobile devices.

Use cases for Redis include:

  • authentication, authorization
  • frequently used queries
  • real time data
  • stats
  • anti spam
  • cybersecurity
  • shopping cart and site sessions
  • Redis' Pub/Sub functionality makes it easy to keep a map of who is interested in updates and distribute the information to those interested.
  • Caching. Redis can be used in the same manner as memcache.

Redis provides more features than memcached, including persistence, complex data types, replication and more. Redis does everything memcached does, often better. Any performance advantage for memcached is minor and workload specific.

Redis' multi model data design enables much greater flexibility in terms of how applications are structured, while providing solid performance and reliability. This enables you to focus on your core product, instead having to spend time and effort implementing your own key value data stores.

Connecting to and accessing Redis data from your C++ application is straightforward and simple.

#include "Poco/Redis/Redis.h"
#include "Poco/Redis/Client.h"
#include "Poco/Redis/AsyncReader.h"
#include "Poco/Redis/Command.h"
#include "Poco/Redis/PoolableConnectionFactory.h"
#include "Poco/Redis/Array.h"

bool sendAuth(Client& client, const std::string& pwd) {
	Array cmd;
	cmd << "AUTH" << pwd;

	std::string response;

	try {
		response = client.execute<std::string>(cmd);
	catch (...) {
		return  false;

	return (response == "OK");

std::string get_redis_key(std::string key) {

	Client client;
	client.connect("localhost", 6379);

	if (!sendAuth(client, "<PASSWORD>")) {
		std::cout << "authentication failure!" << std::endl;

	Command getCommand = Command::get(key);
		BulkString result = client.execute<BulkString>(getCommand);
		std::cout << result << "\n";;
		return result;
	catch (RedisException& e)
		std::cout << e.message() << "\n";;
		return e.message();
	catch (Poco::BadCastException& e)
		std::cout << e.message() << "\n";;
		return e.message();
	return "No result";

As you can see, getting the performance benefits of Redis in memory data with your POCO C++ application is a snap.