Archived
1
0
This commit is contained in:
Jeff Becker 2018-03-09 10:12:50 -05:00
parent c5479e2386
commit 7abd41eecd
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05
5 changed files with 17 additions and 11 deletions

View File

@ -13,7 +13,7 @@ type CacheHandler interface {
type CacheInterface interface { type CacheInterface interface {
RegenAll() RegenAll()
RegenFrontPage() RegenFrontPage(pagesstart int)
RegenOnModEvent(newsgroup, msgid, root string, page int) RegenOnModEvent(newsgroup, msgid, root string, page int)
RegenerateBoard(group string) RegenerateBoard(group string)
Regen(msg ArticleEntry) Regen(msg ArticleEntry)

View File

@ -145,7 +145,7 @@ func (self *FileCache) pollRegen() {
// regen ukko // regen ukko
case _ = <-self.ukkoTicker.C: case _ = <-self.ukkoTicker.C:
self.regenUkko() self.regenUkko()
self.RegenFrontPage() self.RegenFrontPage(0)
case _ = <-self.regenThreadTicker.C: case _ = <-self.regenThreadTicker.C:
self.regenThreadLock.Lock() self.regenThreadLock.Lock()
for _, entry := range self.regenThreadMap { for _, entry := range self.regenThreadMap {
@ -228,7 +228,7 @@ func (self *FileCache) regenerateCatalog(board string) {
} }
// regenerate the front page // regenerate the front page
func (self *FileCache) RegenFrontPage() { func (self *FileCache) RegenFrontPage(_ int) {
indexwr, err1 := os.Create(filepath.Join(self.webroot_dir, "index.html")) indexwr, err1 := os.Create(filepath.Join(self.webroot_dir, "index.html"))
defer indexwr.Close() defer indexwr.Close()
if err1 != nil { if err1 != nil {

View File

@ -228,7 +228,8 @@ func (self *httpFrontend) RegenerateBoard(board string) {
} }
func (self *httpFrontend) RegenFrontPage() { func (self *httpFrontend) RegenFrontPage() {
self.cache.RegenFrontPage() pages, _ := self.daemon.database.GetUkkoPageCount(10)
self.cache.RegenFrontPage(int(pages))
} }
func (self httpFrontend) regenAll() { func (self httpFrontend) regenAll() {
@ -367,7 +368,7 @@ func (self *httpFrontend) poll_liveui() {
func (self *httpFrontend) poll() { func (self *httpFrontend) poll() {
// regenerate front page // regenerate front page
self.cache.RegenFrontPage() self.RegenFrontPage()
// trigger regen // trigger regen
if self.regen_on_start { if self.regen_on_start {

View File

@ -246,7 +246,7 @@ func (self *NullCache) DeleteThreadMarkup(root_post_id string) {
func (self *NullCache) RegenAll() { func (self *NullCache) RegenAll() {
} }
func (self *NullCache) RegenFrontPage() { func (self *NullCache) RegenFrontPage(pagestart int) {
} }
func (self *NullCache) SetRequireCaptcha(required bool) { func (self *NullCache) SetRequireCaptcha(required bool) {

View File

@ -82,20 +82,25 @@ func (self *VarnishCache) RegenAll() {
} }
} }
func (self *VarnishCache) RegenFrontPage() { func (self *VarnishCache) RegenFrontPage(pagestart int) {
self.invalidate(fmt.Sprintf("%s%s", self.varnish_url, self.prefix)) self.invalidate(fmt.Sprintf("%s%s", self.varnish_url, self.prefix))
// TODO: this is also lazy af // TODO: this is also lazy af
self.invalidate(fmt.Sprintf("%s%shistory.html", self.varnish_url, self.prefix)) self.invalidate(fmt.Sprintf("%s%shistory.html", self.varnish_url, self.prefix))
self.invalidateUkko(10) if self.handler.invertPagination {
self.invalidateUkko(50, pagestart-50)
} else {
self.invalidateUkko(pagestart, 0)
}
} }
func (self *VarnishCache) invalidateUkko(pages int) { func (self *VarnishCache) invalidateUkko(pages, start int) {
self.invalidate(fmt.Sprintf("%s%sukko.html", self.varnish_url, self.prefix)) self.invalidate(fmt.Sprintf("%s%sukko.html", self.varnish_url, self.prefix))
self.invalidate(fmt.Sprintf("%s%so/", self.varnish_url, self.prefix)) self.invalidate(fmt.Sprintf("%s%so/", self.varnish_url, self.prefix))
self.invalidate(fmt.Sprintf("%s%sukko.json", self.varnish_url, self.prefix)) self.invalidate(fmt.Sprintf("%s%sukko.json", self.varnish_url, self.prefix))
self.invalidate(fmt.Sprintf("%s%so/json", self.varnish_url, self.prefix)) self.invalidate(fmt.Sprintf("%s%so/json", self.varnish_url, self.prefix))
n := 0 n := start
for n < pages { end := start + pages
for n < end {
self.invalidate(fmt.Sprintf("%s%so/%d/json", self.varnish_url, self.prefix, n)) self.invalidate(fmt.Sprintf("%s%so/%d/json", self.varnish_url, self.prefix, n))
self.invalidate(fmt.Sprintf("%s%so/%d/", self.varnish_url, self.prefix, n)) self.invalidate(fmt.Sprintf("%s%so/%d/", self.varnish_url, self.prefix, n))
n++ n++