mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-10-03 15:38:36 +00:00
ported uwsgi.cache_keys to pypy
This commit is contained in:
@@ -1942,3 +1942,15 @@ struct uwsgi_cache_item *uwsgi_cache_keys(struct uwsgi_cache *uc, uint64_t *pos,
|
||||
(*pos)++;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void uwsgi_cache_rlock(struct uwsgi_cache *uc) {
|
||||
uwsgi_rlock(uc->lock);
|
||||
}
|
||||
|
||||
void uwsgi_cache_rwunlock(struct uwsgi_cache *uc) {
|
||||
uwsgi_rwunlock(uc->lock);
|
||||
}
|
||||
|
||||
char *uwsgi_cache_item_key(struct uwsgi_cache_item *uci) {
|
||||
return uci->key;
|
||||
}
|
||||
|
||||
@@ -125,6 +125,20 @@ struct uwsgi_buffer {
|
||||
...;
|
||||
};
|
||||
|
||||
struct uwsgi_lock_item {
|
||||
...;
|
||||
};
|
||||
|
||||
struct uwsgi_cache {
|
||||
struct uwsgi_lock_item *lock;
|
||||
...;
|
||||
};
|
||||
|
||||
struct uwsgi_cache_item {
|
||||
uint64_t keysize;
|
||||
...;
|
||||
};
|
||||
|
||||
struct uwsgi_server {
|
||||
char hostname[];
|
||||
int mywid;
|
||||
@@ -184,6 +198,11 @@ int uwsgi_cache_magic_set(char *, uint16_t, char *, uint64_t, uint64_t, uint64_t
|
||||
int uwsgi_cache_magic_del(char *, uint16_t, char *);
|
||||
int uwsgi_cache_magic_exists(char *, uint16_t, char *);
|
||||
int uwsgi_cache_magic_clear(char *);
|
||||
struct uwsgi_cache *uwsgi_cache_by_name(char *);
|
||||
void uwsgi_cache_rlock(struct uwsgi_cache *);
|
||||
void uwsgi_cache_rwunlock(struct uwsgi_cache *);
|
||||
char *uwsgi_cache_item_key(struct uwsgi_cache_item *);
|
||||
struct uwsgi_cache_item *uwsgi_cache_keys(struct uwsgi_cache *, uint64_t *, struct uwsgi_cache_item **);
|
||||
|
||||
int uwsgi_add_file_monitor(uint8_t, char *);
|
||||
int uwsgi_add_timer(uint8_t, int);
|
||||
@@ -541,6 +560,21 @@ def uwsgi_pypy_uwsgi_cache_del(key, cache=ffi.NULL):
|
||||
raise Exception('unable to delete item from the cache')
|
||||
uwsgi.cache_del = uwsgi_pypy_uwsgi_cache_del
|
||||
|
||||
def uwsgi_pypy_uwsgi_cache_keys(cache=ffi.NULL):
|
||||
uc = lib.uwsgi_cache_by_name(cache)
|
||||
if uc == ffi.NULL:
|
||||
raise Exception('no local uWSGI cache available')
|
||||
l = []
|
||||
lib.uwsgi_cache_rlock(uc)
|
||||
pos = ffi.new('uint64_t *')
|
||||
uci = ffi.new('struct uwsgi_cache_item **')
|
||||
while True:
|
||||
uci[0] = lib.uwsgi_cache_keys(uc, pos, uci)
|
||||
if uci[0] == ffi.NULL: break
|
||||
l.append(ffi.string(lib.uwsgi_cache_item_key(uci[0]), uci[0].keysize))
|
||||
lib.uwsgi_cache_rwunlock(uc)
|
||||
return l
|
||||
uwsgi.cache_keys = uwsgi_pypy_uwsgi_cache_keys
|
||||
|
||||
def uwsgi_pypy_uwsgi_add_timer(signum, secs):
|
||||
if lib.uwsgi_add_timer(signum, secs) < 0:
|
||||
|
||||
@@ -4151,6 +4151,9 @@ void uwsgi_exit(int) __attribute__ ((__noreturn__));
|
||||
void uwsgi_fallback_config();
|
||||
|
||||
struct uwsgi_cache_item *uwsgi_cache_keys(struct uwsgi_cache *, uint64_t *, struct uwsgi_cache_item **);
|
||||
void uwsgi_cache_rlock(struct uwsgi_cache *);
|
||||
void uwsgi_cache_rwunlock(struct uwsgi_cache *);
|
||||
char *uwsgi_cache_item_key(struct uwsgi_cache_item *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user