2018-09-19 06:09:03 +00:00
|
|
|
// Highly experimental plugin for caching rendered pages for guests
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"sync/atomic"
|
|
|
|
|
2018-10-27 03:21:02 +00:00
|
|
|
"github.com/Azareal/Gosora/common"
|
2018-09-19 06:09:03 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var hyperPageCache *HyperPageCache
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
common.Plugins.Add(&common.Plugin{UName: "hyperdrive", Name: "Hyperdrive", Author: "Azareal", Init: initHyperdrive, Deactivate: deactivateHyperdrive})
|
|
|
|
}
|
|
|
|
|
2019-02-17 05:38:49 +00:00
|
|
|
func initHyperdrive(plugin *common.Plugin) error {
|
2018-09-19 06:09:03 +00:00
|
|
|
hyperPageCache = newHyperPageCache()
|
2019-02-17 05:38:49 +00:00
|
|
|
plugin.AddHook("somewhere", deactivateHyperdrive)
|
2018-09-19 06:09:03 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-02-17 05:38:49 +00:00
|
|
|
func deactivateHyperdrive(plugin *common.Plugin) {
|
2018-09-19 06:09:03 +00:00
|
|
|
hyperPageCache = nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type HyperPageCache struct {
|
|
|
|
topicList atomic.Value
|
|
|
|
}
|
|
|
|
|
|
|
|
func newHyperPageCache() *HyperPageCache {
|
|
|
|
pageCache := new(HyperPageCache)
|
|
|
|
pageCache.topicList.Store([]byte(""))
|
|
|
|
return pageCache
|
|
|
|
}
|