// get an item from the cache func CacheGet(key string) []byte { if int(C.uwsgi_cache_enabled()) == 0 { return nil } k := C.CString(key) defer C.free(unsafe.Pointer(k)) kl := len(key) var vl C.uint64_t = C.uint64_t(0) C.uwsgi_cache_rlock() c_value := C.uwsgi_cache_get(k, C.uint16_t(kl), &vl) var p []byte if vl > 0 { p = C.GoBytes((unsafe.Pointer)(c_value), C.int(vl)) } else { p = nil } C.uwsgi_cache_rwunlock() return p }
// check if an item exists in the cache func CacheExists(key string) bool { if int(C.uwsgi_cache_enabled()) == 0 { return false } k := C.CString(key) defer C.free(unsafe.Pointer(k)) kl := len(key) C.uwsgi_cache_rlock() if int(C.uwsgi_cache_exists(k, C.uint16_t(kl))) > 0 { C.uwsgi_cache_rwunlock() return true } C.uwsgi_cache_rwunlock() return false }
// check if an item exists in the cache func CacheExists(key string) bool { if (C.uwsgi.caches) == nil { return false } k := C.CString(key) defer C.free(unsafe.Pointer(k)) kl := len(key) C.uwsgi_cache_rlock(C.uwsgi.caches) if int(C.uwsgi_cache_exists2(C.uwsgi.caches, k, C.uint16_t(kl))) > 0 { C.uwsgi_cache_rwunlock(C.uwsgi.caches) return true } C.uwsgi_cache_rwunlock(C.uwsgi.caches) return false }