Skip to content

v0.0.12

Choose a tag to compare

@localrivet localrivet released this 04 Dec 22:34
· 22 commits to main since this release

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:*")