Skip to content

Commit e7f8dd2

Browse files
committed
REFACTOR: refactor config file support for server configuration
1 parent 9e93d37 commit e7f8dd2

File tree

4 files changed

+374
-30
lines changed

4 files changed

+374
-30
lines changed

arcus.conf

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
# ============================================================
2+
# Arcus-memcached Configuration File
3+
#
4+
# This file is used to configure the Arcus-memcached server at startup.
5+
#
6+
# Usage:
7+
# ./memcached -c arcus.conf
8+
# ./memcached -c arcus.conf -p 20000 (CLI options override config file settings)
9+
#
10+
# Format:
11+
# key=value
12+
# Lines starting with '#' are treated as comments.
13+
# ============================================================
14+
15+
16+
# [Required] Path to the storage engine library (.so).
17+
# This must be specified to start the server.
18+
engine_path=.libs/default_engine.so
19+
20+
# TCP port number to listen on. (Default: 11211)
21+
port=11211
22+
23+
# UDP port number to listen on. (Default: 0)
24+
# udpport=0
25+
26+
# The IP address of the network interface to listen on.
27+
# 0.0.0.0 means listen on all available interfaces (INADDR_ANY).
28+
listen=0.0.0.0
29+
30+
# Path to the UNIX socket file.
31+
# socketpath=/tmp/memcached.sock
32+
33+
# Access mask for the UNIX socket in octal. (Default: 0700)
34+
# access=0700
35+
36+
# Assume the identity of <username> (drops root privileges).
37+
# Effectively switches the user after starting.
38+
# username=nobody
39+
40+
# Number of worker threads to process incoming requests. (Default: 4)
41+
# Typically set to the number of CPU cores.
42+
threads=4
43+
44+
# Maximum number of simultaneous connections. (Default: 1024)
45+
# Connections exceeding this limit may be queued or rejected.
46+
maxconns=1024
47+
48+
# Backlog queue limit for pending connections. (Default: 1024)
49+
backlog=1024
50+
51+
# Maximum number of requests per event. (Default: 20)
52+
# Limits the number of requests processed for a given connection to prevent starvation.
53+
reqs_per_event=20
54+
55+
# Maximum memory to use for item storage. (Default: 64)
56+
memory_limit=64M
57+
58+
# Maximum size of a single item. (Default: 1m)
59+
# Supports K and M suffixes. Min: 1k, Max: 128m.
60+
# Adjusting this value also adjusts the slab page size.
61+
item_size_max=1m
62+
63+
# Action to take when memory is exhausted. (Default: false)
64+
# false = Evict old items (LRU) to make space.
65+
# true = Return an error instead of evicting items.
66+
eviction=false
67+
68+
# Chunk size growth factor between slab classes. (Default: 1.25)
69+
# Controls the size increase of chunks in subsequent slab classes.
70+
factor=1.25
71+
72+
# Minimum space allocated for key+value+flags. (Default: 48)
73+
chunk_size=48
74+
75+
# Sticky (gummed) memory limit in MB. (Default: 0 - Unlimited)
76+
# Reserved memory for items that should not be evicted.
77+
sticky_limit=0
78+
79+
# Use large memory pages if available. (Default: false)
80+
# Can improve performance by reducing TLB misses.
81+
preallocate=false
82+
83+
# These options control the behavior of the Arcus storage engine,
84+
# including Collection features (List, Set, Map, B+Tree).
85+
86+
# Enable CAS (Check-And-Set) feature. (Default: true)
87+
# Ensures data consistency. Set to false to disable.
88+
use_cas=true
89+
90+
# Raw configuration string passed directly to the engine.
91+
# Format: param1=val1;param2=val2...
92+
# engine_config=conf/default_engine.conf
93+
94+
# Character to use as a delimiter for key prefixes in stats. (Default: :)
95+
# If specified, per-prefix stats collection is automatically enabled.
96+
prefix_delimiter=:
97+
98+
# Enable detailed stats collection. (Default: false)
99+
# Automatically enabled if 'prefix_delimiter' is set.
100+
detail_enabled=false
101+
102+
# Allow the 'stats detail' command to be used. (Default: true)
103+
allow_detailed=true
104+
105+
# Run as a daemon (background process). (Default: false)
106+
daemonize=false
107+
108+
# File to write the Process ID (PID) to when running as a daemon.
109+
# pid_file=/var/run/memcached.pid
110+
111+
# Verbose logging level. (Default: 3)
112+
# 0 = Detail, 1 = Debug, 2 = Info, 3 = Warning
113+
# Higher values result in less logging.
114+
verbosity=3
115+
116+
# Limit the size of the core file. (Default: 0)
117+
# Used for debugging purposes to allow core dumps.
118+
maxcore=0
119+
120+
# Lock down all paged memory. (Default: false)
121+
# Prevents memory from being swapped out, but may fail if system limit is exceeded.
122+
lock_memory=false
123+
124+
# Path to the UNIX socket file (if used).
125+
# socketpath=/tmp/memcached.sock
126+
127+
# Access mask for the UNIX socket in octal. (Default: 0700)
128+
# access=0700
129+
130+
# Protocol to use (auto, binary, ascii). (Default: auto)
131+
protocol=auto
132+
133+
# Load extension libraries (.so).
134+
# Used to load additional modules like loggers or management tools.
135+
# extension1=/usr/local/lib/logger.so
136+
# extension2=/usr/local/lib/management.so
137+
138+
# Settings required
139+
140+
# ZooKeeper ensemble server list.
141+
# Only available if compiled with ZooKeepr support.
142+
# Format: host1:port1,host2:port2,...
143+
# zookeeper=zk1.local:2181,zk2.local:2181,zk3.local:2181
144+
145+
# ZooKeeper session timeout in milliseconds. (Default: 0 -> Uses internal default)
146+
# Only available if compiled with ZooKeepr support.
147+
# Recommended value: > 10 and < 20000 (check internal implementation limits).
148+
# zk_timeout=3000
149+
150+
# Proxy configuration (if compiled with proxy support)
151+
# proxy_config=...
152+
153+
# Require SASL authentication for connections. (Default: false)
154+
# Only available if compiled with SASL support.
155+
# require_sasl=false

config_parser.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626
#include <memcached/config_parser.h>
2727
#include <memcached/util.h>
2828

29-
static int read_config_file(const char *fname, struct config_item items[],
30-
FILE *error);
31-
3229
/**
3330
* Copy a string and trim of leading and trailing white space characters.
3431
* Allow the user to escape out the stop character by putting a backslash before
@@ -224,8 +221,7 @@ int parse_config(const char *str, struct config_item *items, FILE *error) {
224221
return ret;
225222
}
226223

227-
static int read_config_file(const char *fname, struct config_item items[],
228-
FILE *error) {
224+
int read_config_file(const char *fname, struct config_item items[], FILE *error) {
229225
FILE *fp = fopen(fname, "r");
230226
if (fp == NULL) {
231227
(void)fprintf(error, "Failed to open file: %s\n", fname);

include/memcached/config_parser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ struct config_item {
7777
*/
7878
MEMCACHED_PUBLIC_API int parse_config(const char *str, struct config_item items[], FILE *error);
7979

80+
int read_config_file(const char *fname, struct config_item items[], FILE *error);
8081
#ifdef __cplusplus
8182
}
8283
#endif

0 commit comments

Comments
 (0)