File: session.c

package info (click to toggle)
uwsgi 2.0.31-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,564 kB
  • sloc: ansic: 87,066; python: 7,004; cpp: 1,133; java: 708; perl: 678; sh: 585; ruby: 555; makefile: 148; xml: 130; cs: 121; objc: 37; php: 28; erlang: 20; javascript: 11
file content (52 lines) | stat: -rw-r--r-- 999 bytes parent folder | download
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
#include "common.h"

PS_OPEN_FUNC(uwsgi) {
	PS_SET_MOD_DATA((char *)save_path);
	return SUCCESS;
}

PS_CLOSE_FUNC(uwsgi) {
	return SUCCESS;
}

PS_READ_FUNC(uwsgi) {
	char *cache = PS_GET_MOD_DATA();
	uint64_t valsize = 0;
	char *value = uwsgi_cache_magic_get(key->val, key->len , &valsize, NULL, cache);
	if (!value) {
		*val = ZSTR_EMPTY_ALLOC();
		return SUCCESS;
	}
	*val = zend_string_init(value, valsize, 0);
	return SUCCESS;
	
}

PS_WRITE_FUNC(uwsgi) {
	char *cache = PS_GET_MOD_DATA();
	if (val->len == 0) return SUCCESS;
	if (!uwsgi_cache_magic_set(key->val, key->len, val->val, val->len, 0, UWSGI_CACHE_FLAG_UPDATE, cache)) {
		return SUCCESS;	
	}
	return FAILURE;
}

PS_DESTROY_FUNC(uwsgi) {
	char *cache = PS_GET_MOD_DATA();
	if (!uwsgi_cache_magic_exists(key->val, key->len, cache))
		return SUCCESS;

	if (!uwsgi_cache_magic_del(key->val, key->len, cache)) {
		return SUCCESS;
	}
	return FAILURE;
}

PS_GC_FUNC(uwsgi) {
	return SUCCESS;
}

ps_module ps_mod_uwsgi = {
	PS_MOD(uwsgi)
};