gosora/experimental/plugin_hyperdrive.go

35 lines
730 B
Go
Raw Normal View History

// Highly experimental plugin for caching rendered pages for guests
package main
import (
"sync/atomic"
"./common"
)
var hyperPageCache *HyperPageCache
func init() {
common.Plugins.Add(&common.Plugin{UName: "hyperdrive", Name: "Hyperdrive", Author: "Azareal", Init: initHyperdrive, Deactivate: deactivateHyperdrive})
}
func initHyperdrive() error {
hyperPageCache = newHyperPageCache()
common.Plugins["hyperdrive"].AddHook("somewhere", deactivateHyperdrive)
return nil
}
func deactivateHyperdrive() {
hyperPageCache = nil
}
type HyperPageCache struct {
topicList atomic.Value
}
func newHyperPageCache() *HyperPageCache {
pageCache := new(HyperPageCache)
pageCache.topicList.Store([]byte(""))
return pageCache
}