예제 #1
0
파일: ybc.go 프로젝트: inthecloud247/ybc
// Stores value with the given key and the given ttl in the cache.
//
// Do not use this method for storing big values in the cache such as video
// files - use Cache.NewSetTxn() instead.
func (cache *Cache) Set(key []byte, value []byte, ttl time.Duration) error {
	cache.dg.CheckLive()
	k := newKey(key)
	v := newValue(value, ttl)
	if C.ybc_item_set(cache.ctx(), &k, &v) == 0 {
		return ErrNoSpace
	}
	return nil
}
예제 #2
0
파일: ybc.go 프로젝트: rjmcguire/ybc
// Stores value with the given key and the given ttl in the cache.
//
// Do not use this method for storing big values in the cache such as video
// files - use Cache.NewSetTxn() instead.
func (cache *Cache) Set(key []byte, value []byte, ttl time.Duration) error {
	cache.dg.CheckLive()
	var k C.struct_ybc_key
	initKey(&k, key)
	var v C.struct_ybc_value
	initValue(&v, value, ttl)
	if C.ybc_item_set(cache.ctx(), &k, &v) == 0 {
		return ErrNoSpace
	}
	return nil
}