all repos — honk @ ed3081fef27ccf14f0282dccad9bbb8cac1ae70e

my fork of honk

cache users table
Ted Unangst tedu@tedunangst.com
Mon, 07 Oct 2019 15:29:34 -0400
commit

ed3081fef27ccf14f0282dccad9bbb8cac1ae70e

parent

97d8352e41b74e20305437dcc1d5202700e65d97

2 files changed, 16 insertions(+), 3 deletions(-)

jump to
M database.godatabase.go

@@ -28,14 +28,26 @@

"humungus.tedunangst.com/r/webs/login" ) -func butwhatabout(name string) (*WhatAbout, error) { +var someusers = cacheNew(cacheOptions { Filler: func(name string) (*WhatAbout, bool) { row := stmtWhatAbout.QueryRow(name) - var user WhatAbout + user := new (WhatAbout) var options string err := row.Scan(&user.ID, &user.Name, &user.Display, &user.About, &user.Key, &options) + if err != nil { + return nil, false + } user.URL = fmt.Sprintf("https://%s/%s/%s", serverName, userSep, user.Name) user.SkinnyCSS = strings.Contains(options, " skinny ") - return &user, err + return user, true +}}) + +func butwhatabout(name string) (*WhatAbout, error) { + var user *WhatAbout + ok := someusers.Get(name, &user) + if !ok { + return nil, fmt.Errorf("no user: %s", name) + } + return user, nil } func gethonkers(userid int64) []*Honker {
M web.goweb.go

@@ -734,6 +734,7 @@ _, err := db.Exec("update users set about = ?, options = ? where username = ?", whatabout, options, u.Username)

if err != nil { log.Printf("error bouting what: %s", err) } + someusers.Clear(u.Username) http.Redirect(w, r, "/account", http.StatusSeeOther) }