You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
typeCacherinterface {
// Cache caches the result of a Select or SelectDoc. If id is not provided, an FNV checksum// of the SQL is used as the id. (If interpolation is set, arguments are hashed). Use invalidate to // immediately invalidate the cache to force setting its value.Cache(idstring, duration time.Duration, invalidatebool)
}
// cache pre-defined game information for a weekDB.SelectDoc("*").
From("games").
Cache("games", 7*24*time.Hour, false).
QueryStruct(&games)
// cache user information for 30 secondsDB.SelectDoc("*").
From("users").
Where("user_id = $1", id).
Cache("", 30*time.Second, false).
QueryStruct(&user)
// invalidates cache for key "games"DB.InvalidateCache("games")
// invalidates all
DB.InvalidateCache(")
The text was updated successfully, but these errors were encountered:
Neat idea. I assume the implementation of Cache is to fall back to querying directly if the hash of the query (or query + args) does not exist in Redis?
I'd be curious to see the benchmarks for a "big set of cached results from Redis" vs. "big set of cached results from the DB" (given that Postgres caches too).
Implement caching using Redis.
The text was updated successfully, but these errors were encountered: