aboutsummaryrefslogtreecommitdiff
path: root/src/zen/cmds/cache_cmd.h
blob: 73702cada0f83949f9dedf07a0277c4e8bcd6dcb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// Copyright Epic Games, Inc. All Rights Reserved.

#pragma once

#include "../zen.h"

namespace zen {

class DropCommand : public CacheStoreCommand
{
public:
	DropCommand();
	~DropCommand();

	virtual int				  Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) override;
	virtual cxxopts::Options& Options() override { return m_Options; }

private:
	cxxopts::Options m_Options{"drop", "Drop cache namespace or bucket"};
	std::string		 m_HostName;
	std::string		 m_NamespaceName;
	std::string		 m_BucketName;
};

class CacheInfoCommand : public CacheStoreCommand
{
public:
	CacheInfoCommand();
	~CacheInfoCommand();
	virtual int				  Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) override;
	virtual cxxopts::Options& Options() override { return m_Options; }

private:
	cxxopts::Options m_Options{"cache-info", "Info on cache, namespace or bucket"};
	std::string		 m_HostName;
	std::string		 m_NamespaceName;
	std::string		 m_SizeInfoBucketNames;
	bool			 m_BucketSizeInfo = false;
	std::string		 m_BucketName;
};

class CacheStatsCommand : public CacheStoreCommand
{
public:
	CacheStatsCommand();
	~CacheStatsCommand();
	virtual int				  Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) override;
	virtual cxxopts::Options& Options() override { return m_Options; }

private:
	cxxopts::Options m_Options{"cache-stats", "Stats info on cache"};
	std::string		 m_HostName;
};

class CacheDetailsCommand : public CacheStoreCommand
{
public:
	CacheDetailsCommand();
	~CacheDetailsCommand();
	virtual int				  Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) override;
	virtual cxxopts::Options& Options() override { return m_Options; }

private:
	cxxopts::Options m_Options{"cache-details", "Detailed info on cache"};
	std::string		 m_HostName;
	bool			 m_CSV				 = false;
	bool			 m_Details			 = false;
	bool			 m_AttachmentDetails = false;
	std::string		 m_Namespace;
	std::string		 m_Bucket;
	std::string		 m_ValueKey;
};

class CacheGenerateCommand : public CacheStoreCommand
{
public:
	static constexpr char Name[]		= "cache-gen";
	static constexpr char Description[] = "Generates cache values into a bucket";

	CacheGenerateCommand();
	~CacheGenerateCommand();
	virtual int				  Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) override;
	virtual cxxopts::Options& Options() override { return m_Options; }

private:
	cxxopts::Options m_Options{Name, Description};
	std::string		 m_HostName;
	std::string		 m_Namespace;
	std::string		 m_Bucket;
	uint64_t		 m_Count = 1;

	uint64_t m_MinSize			  = 0;
	uint64_t m_MaxSize			  = 0;
	uint32_t m_MinAttachmentCount = 0;
	uint32_t m_MaxAttachmentCount = 0;
};

class CacheGetCommand : public CacheStoreCommand
{
public:
	static constexpr char Name[]		= "cache-get";
	static constexpr char Description[] = "Get cache values/records or attachments from a bucket";

	CacheGetCommand();
	~CacheGetCommand();

	virtual int				  Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) override;
	virtual cxxopts::Options& Options() override { return m_Options; }

private:
	cxxopts::Options m_Options{Name, Description};
	std::string		 m_HostName;
	std::string		 m_Namespace;
	std::string		 m_Bucket;
	std::string		 m_ValueKey;
	std::string		 m_AttachmentHash;
	std::string		 m_OutputPath;
	bool			 m_AsText	  = false;
	bool			 m_Decompress = true;
};

}  // namespace zen