Example #1
0
// remove an intem from the cache
func CacheDel(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_wlock()

	if int(C.uwsgi_cache_del(k, C.uint16_t(kl), C.uint64_t(0))) < 0 {
		C.uwsgi_cache_rwunlock()
		return false
	}

	C.uwsgi_cache_rwunlock()
	return true
}
Example #2
0
// remove an intem from the cache
func CacheDel(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_wlock(C.uwsgi.caches)

	if int(C.uwsgi_cache_del2(C.uwsgi.caches, k, C.uint16_t(kl), C.uint64_t(0), C.uint16_t(0))) < 0 {
		C.uwsgi_cache_rwunlock(C.uwsgi.caches)
		return false
	}

	C.uwsgi_cache_rwunlock(C.uwsgi.caches)
	return true
}
Example #3
0
// put an item in the cache
func CacheSetFlags(key string, p []byte, expires uint64, flags int) bool {

	if int(C.uwsgi_cache_enabled()) == 0 {
		return false
	}

	k := C.CString(key)
	defer C.free(unsafe.Pointer(k))
	kl := len(key)
	v := unsafe.Pointer(&p[0])
	vl := len(p)

	C.uwsgi_cache_wlock()

	if int(C.uwsgi_cache_set(k, C.uint16_t(kl), (*C.char)(v), C.uint64_t(vl), C.uint64_t(expires), C.uint16_t(flags))) < 0 {
		C.uwsgi_cache_rwunlock()
		return false
	}

	C.uwsgi_cache_rwunlock()
	return true
}