Repository navigation
v0.0.12
Full Changelog: v0.0.11...v0.0.12
Added redis caching:
// Initialize with MustConnect and options
cache := cache.MustConnect(db,
cache.WithRedisURL("redis:6379"),
cache.WithPassword("mypassword"),
cache.WithDB(0),
)
defer cache.Close()
// Use the cache
var post Post
err := cache.Get(ctx, "post:123", &post, func() error {
return post.GetByID(ctx, cache.GetDB(), 123)
})
// Set with operation
err = cache.Set(ctx, "post:123", 24*time.Hour, &post, func() error {
return post.Update(ctx, cache.GetDB())
})
// Delete cache entries
cache.Del(ctx, "post:123")
cache.DelByPattern(ctx, "post:*")