当前位置: 首页>>代码示例>>Golang>>正文


Golang Bucket.Delete方法代码示例

本文整理汇总了Golang中github.com/boltdb/bolt.Bucket.Delete方法的典型用法代码示例。如果您正苦于以下问题:Golang Bucket.Delete方法的具体用法?Golang Bucket.Delete怎么用?Golang Bucket.Delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/boltdb/bolt.Bucket的用法示例。


在下文中一共展示了Bucket.Delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Del

func (store *BoltStore) Del(uri string) error {
	namespace, key := util.NamespaceKey(uri)
	bucketkeys := util.PathFolders(namespace)
	var bucket *bolt.Bucket = nil
	var err error
	e := store.db.Update(func(tx *bolt.Tx) error {
		for _, bucketkey := range bucketkeys {
			if bucket == nil {
				bucket, err = tx.CreateBucketIfNotExists([]byte(bucketkey))
				if err != nil {
					return err
				}
			} else {
				bucket, err = bucket.CreateBucketIfNotExists([]byte(bucketkey))
				if err != nil {
					return err
				}
			}
		}
		bucket.DeleteBucket([]byte(key))
		bucket.Delete([]byte(key))
		return nil
	})
	return e
}
开发者ID:h2object,项目名称:h2object,代码行数:25,代码来源:store_bolt.go

示例2: commitBucketSiacoinOutputDiff

// commitSiacoinOutputDiff applies or reverts a SiacoinOutputDiff from within
// a database transaction.
func (cs *ConsensusSet) commitBucketSiacoinOutputDiff(scoBucket *bolt.Bucket, scod modules.SiacoinOutputDiff, dir modules.DiffDirection) error {
	if build.DEBUG && (scoBucket.Get(scod.ID[:]) == nil) != (scod.Direction == dir) {
		panic(errRepeatInsert)
	}
	if scod.Direction == dir {
		return scoBucket.Put(scod.ID[:], encoding.Marshal(scod.SiacoinOutput))
	}
	return scoBucket.Delete(scod.ID[:])
}
开发者ID:kustomzone,项目名称:Sia,代码行数:11,代码来源:diffs.go

示例3: deleteRange

func deleteRange(bucket *bolt.Bucket, prefix tuple.Key) error {
	cursor := bucket.Cursor()
	for k, _ := cursor.Seek(prefix); k != nil && bytes.HasPrefix(k, prefix); k, _ = cursor.Next() {
		if err := bucket.Delete(k); err != nil {
			return err
		}
	}
	return nil
}
开发者ID:smarterclayton,项目名称:kube-archiver,代码行数:9,代码来源:bolt.go

示例4: deleteChanTotalFlow

func deleteChanTotalFlow(openChanBucket *bolt.Bucket, chanID []byte) error {
	keyPrefix := make([]byte, 3+len(chanID))
	copy(keyPrefix[3:], chanID)

	copy(keyPrefix[:3], satSentPrefix)
	if err := openChanBucket.Delete(keyPrefix); err != nil {
		return err
	}

	copy(keyPrefix[:3], satRecievedPrefix)
	return openChanBucket.Delete(keyPrefix)
}
开发者ID:lightningnetwork,项目名称:lnd,代码行数:12,代码来源:channel.go

示例5: sumAndShift

func (db *bwdb) sumAndShift(pullBkt, putBkt *bolt.Bucket, putKey []byte) error {
	//pull all the values out of the pullBkt and sum them
	s := db.newVar()
	err := pullBkt.ForEach(func(k, v []byte) error {
		sx := db.newVar()
		if err := sx.Decode(v); err != nil {
			return err
		}
		if err := s.Add(sx); err != nil {
			return err
		}
		s.SetTS(sx.TS())
		return pullBkt.Delete(k)
	})
	if err != nil {
		return err
	}
	return db.updateVal(putBkt, putKey, s) //if for some reason the key already exists, add it
}
开发者ID:traetox,项目名称:gobwmon,代码行数:19,代码来源:db.go

示例6: Process

// Process makes sure incoming requests do not exceed the configured rate
// limit.
func (RateLimitFilter) Process(h Hook, r Request, b *bolt.Bucket) error {
	amount, _ := strconv.Atoi(string(b.Get([]byte(fmt.Sprintf("%s-amount", h.ID)))))
	interval, _ := strconv.Atoi(string(b.Get([]byte(fmt.Sprintf("%s-interval", h.ID)))))
	if amount <= 0 || interval <= 0 {
		return errors.New("rate limit filter not initialized")
	}

	b = b.Bucket([]byte("requests"))

	// store current timestamp
	now := time.Now()
	k := []byte(fmt.Sprintf("%d", now.UnixNano()))
	if err := b.Put(k, nil); err != nil {
		return err
	}

	// count requests
	c := b.Cursor()
	from := []byte(fmt.Sprintf("%d", now.Add(time.Duration(-interval)*time.Second).UnixNano()))

	var count int
	for k, _ := c.Seek(from); k != nil; k, _ = c.Next() {
		count++
	}

	if count > amount {
		return fmt.Errorf("rate limit exceeded (limit=%d count=%d)", amount, count)
	}

	// cleanup old entries
	for k, _ := c.First(); k != nil && bytes.Compare(k, from) <= 0; k, _ = c.Next() {
		if err := b.Delete(k); err != nil {
			return err
		}
	}
	return nil
}
开发者ID:vampirewalk,项目名称:rehook,代码行数:39,代码来源:rate_limit_filter.go

示例7: deleteChanCapacity

func deleteChanCapacity(openChanBucket *bolt.Bucket, chanID []byte) error {
	keyPrefix := make([]byte, 3+len(chanID))
	copy(keyPrefix[3:], chanID)

	copy(keyPrefix[:3], chanCapacityPrefix)
	if err := openChanBucket.Delete(keyPrefix); err != nil {
		return err
	}

	copy(keyPrefix[:3], selfBalancePrefix)
	if err := openChanBucket.Delete(keyPrefix); err != nil {
		return err
	}

	copy(keyPrefix[:3], theirBalancePrefix)
	return openChanBucket.Delete(keyPrefix)
}
开发者ID:lightningnetwork,项目名称:lnd,代码行数:17,代码来源:channel.go

示例8: DepersistOneBoltTx

func DepersistOneBoltTx(bucket *bolt.Bucket, key string) error {
	return bucket.Delete([]byte(key))
}
开发者ID:jeffjenkins,项目名称:dispatchd,代码行数:3,代码来源:persist.go

示例9: deleteChannelIDs

func deleteChannelIDs(nodeChanBucket *bolt.Bucket, chanID []byte) error {
	idKey := make([]byte, len(chanIDKey)+len(chanID))
	copy(idKey[:3], chanIDKey)
	copy(idKey[3:], chanID)
	return nodeChanBucket.Delete(idKey)
}
开发者ID:lightningnetwork,项目名称:lnd,代码行数:6,代码来源:channel.go

示例10: deleteChanNetFee

func deleteChanNetFee(openChanBucket *bolt.Bucket, chanID []byte) error {
	keyPrefix := make([]byte, 3+len(chanID))
	copy(keyPrefix, netFeesPrefix)
	copy(keyPrefix[3:], chanID)
	return openChanBucket.Delete(keyPrefix)
}
开发者ID:lightningnetwork,项目名称:lnd,代码行数:6,代码来源:channel.go

示例11: deleteChanNumUpdates

func deleteChanNumUpdates(openChanBucket *bolt.Bucket, chanID []byte) error {
	keyPrefix := make([]byte, 3+len(chanID))
	copy(keyPrefix, updatePrefix)
	copy(keyPrefix[3:], chanID)
	return openChanBucket.Delete(keyPrefix)
}
开发者ID:lightningnetwork,项目名称:lnd,代码行数:6,代码来源:channel.go

示例12: deleteChanMinFeePerKb

func deleteChanMinFeePerKb(openChanBucket *bolt.Bucket, chanID []byte) error {
	keyPrefix := make([]byte, 3+len(chanID))
	copy(keyPrefix, minFeePerKbPrefix)
	copy(keyPrefix[3:], chanID)
	return openChanBucket.Delete(keyPrefix)
}
开发者ID:lightningnetwork,项目名称:lnd,代码行数:6,代码来源:channel.go

示例13: deleteChanDeliveryScripts

func deleteChanDeliveryScripts(nodeChanBucket *bolt.Bucket, chanID []byte) error {
	deliveryKey := make([]byte, len(deliveryScriptsKey)+len(chanID))
	copy(deliveryKey[:3], deliveryScriptsKey)
	copy(deliveryKey[3:], chanID)
	return nodeChanBucket.Delete(deliveryScriptsKey)
}
开发者ID:lightningnetwork,项目名称:lnd,代码行数:6,代码来源:channel.go

示例14: deleteChanElkremState

func deleteChanElkremState(nodeChanBucket *bolt.Bucket, chanID []byte) error {
	elkremKey := make([]byte, len(elkremStateKey)+len(chanID))
	copy(elkremKey[:3], elkremStateKey)
	copy(elkremKey[3:], chanID)
	return nodeChanBucket.Delete(elkremKey)
}
开发者ID:lightningnetwork,项目名称:lnd,代码行数:6,代码来源:channel.go

示例15: deleteChanFundingInfo

func deleteChanFundingInfo(nodeChanBucket *bolt.Bucket, chanID []byte) error {
	fundTxnKey := make([]byte, len(fundingTxnKey)+len(chanID))
	copy(fundTxnKey[:3], fundingTxnKey)
	copy(fundTxnKey[3:], chanID)
	return nodeChanBucket.Delete(fundTxnKey)
}
开发者ID:lightningnetwork,项目名称:lnd,代码行数:6,代码来源:channel.go


注:本文中的github.com/boltdb/bolt.Bucket.Delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。