本文整理汇总了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
}
示例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[:])
}
示例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
}
示例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)
}
示例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
}
示例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
}
示例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)
}
示例8: DepersistOneBoltTx
func DepersistOneBoltTx(bucket *bolt.Bucket, key string) error {
return bucket.Delete([]byte(key))
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}