This commit is contained in:
parent
7573e47b77
commit
525e11eb6a
|
@ -129,6 +129,7 @@ func handle(ctx *httputils.RequestContext) {
|
||||||
if len(pathElements) > 3 {
|
if len(pathElements) > 3 {
|
||||||
|
|
||||||
if pathElements[3] == "information" {
|
if pathElements[3] == "information" {
|
||||||
|
ctx.SetResponseCode(http.StatusOK)
|
||||||
ctx.SetResponseHeader("Content-Type", "application/json")
|
ctx.SetResponseHeader("Content-Type", "application/json")
|
||||||
if entry != nil {
|
if entry != nil {
|
||||||
b, _ := json.Marshal(struct {
|
b, _ := json.Marshal(struct {
|
||||||
|
@ -158,6 +159,13 @@ func handle(ctx *httputils.RequestContext) {
|
||||||
ctx.ServeBytes(b)
|
ctx.ServeBytes(b)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
} else if pathElements[3] == "drop" { //Drop key from cache
|
||||||
|
ctx.SetResponseCode(http.StatusOK)
|
||||||
|
_ = db.RemoveEntry(key)
|
||||||
|
if entry != nil && !entry.Key.Equals(key) {
|
||||||
|
_ = db.RemoveEntry(&entry.Key)
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: update entries with these instant returns
|
//TODO: update entries with these instant returns
|
||||||
|
|
|
@ -53,6 +53,12 @@ func (db *Database) SetEntry(entry *Entry) error {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (db *Database) RemoveEntry(key *HashIdentifier) error {
|
||||||
|
return db.handle.Update(func(txn *badger.Txn) error {
|
||||||
|
return txn.Delete(key.Encode())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func (db *Database) getChain(txn *badger.Txn, key HashIdentifier) (*Entry, error) {
|
func (db *Database) getChain(txn *badger.Txn, key HashIdentifier) (*Entry, error) {
|
||||||
item, err := txn.Get(key.Encode())
|
item, err := txn.Get(key.Encode())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue