-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.h
46 lines (36 loc) · 1.09 KB
/
server.h
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
// Copyright 2021 Spirache Eduard
#ifndef SERVER_H_
#define SERVER_H_
#include "Hashtable.h"
typedef struct server_memory server_memory;
struct server_memory {
int id;
int replica_id;
unsigned int tag;
hashtable_t* table;
};
server_memory* init_server_memory();
void free_server_memory(server_memory* server);
/**
* server_store() - Stores a key-value pair to the server.
* @arg1: Server which performs the task.
* @arg2: Key represented as a string.
* @arg3: Value represented as a string.
*/
void server_store(server_memory* server, char* key, char* value);
/**
* server_remove() - Removes a key-pair value from the server.
* @arg1: Server which performs the task.
* @arg2: Key represented as a string.
*/
void server_remove(server_memory* server, char* key);
/**
* server_remove() - Gets the value associated with the key.
* @arg1: Server which performs the task.
* @arg2: Key represented as a string.
*
* Return: String value associated with the key
* or NULL (in case the key does not exist).
*/
char* server_retrieve(server_memory* server, char* key);
#endif // SERVER_H_