ClickHouse/src/Storages/StorageRedis.h
2023-06-02 10:05:54 +08:00

54 lines
1.5 KiB
C++

#pragma once
#include <Poco/Redis/Redis.h>
#include <Storages/IStorage.h>
#include <Dictionaries/RedisSource.h>
namespace DB
{
/* Implements storage in the Redis.
* Use ENGINE = Redis(host:port, db_index, password, storage_type, conn_pool_size);
* Read only.
*
* Note If storage_type is
* simple: there should be 2 columns and the first one is key in Redis, the second one is value.
* hash_map: there should be 3 columns and the first one is key in Redis and the second is the field of Redis Map.
*/
class StorageRedis : public IStorage
{
public:
StorageRedis(
const StorageID & table_id_,
const RedisConfiguration & configuration_,
const ColumnsDescription & columns_,
const ConstraintsDescription & constraints_,
const String & comment_);
std::string getName() const override { return "Redis"; }
Pipe read(
const Names & column_names,
const StorageSnapshotPtr & storage_snapshot,
SelectQueryInfo & query_info,
ContextPtr context,
QueryProcessingStage::Enum processed_stage,
size_t max_block_size,
size_t num_streams) override;
SinkToStoragePtr write(
const ASTPtr & query,
const StorageMetadataPtr & /*metadata_snapshot*/,
ContextPtr context) override;
static RedisConfiguration getConfiguration(ASTs engine_args, ContextPtr context);
private:
StorageID table_id;
RedisConfiguration configuration;
Poco::Logger * log;
RedisPoolPtr pool;
};
}