middleware

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCachedUserFeeds

func GetCachedUserFeeds(c *gin.Context, userID int, db database.Database) ([]database.Feed, error)

GetCachedUserFeeds retrieves user feeds from request cache if available, otherwise fetches from database and stores in cache for subsequent calls. This eliminates duplicate GetUserFeeds calls within a single request.

Example usage in handlers:

feeds, err := middleware.GetCachedUserFeeds(c, userID, db)

func RequestCacheMiddleware

func RequestCacheMiddleware() gin.HandlerFunc

RequestCacheMiddleware creates a new request-scoped cache for each HTTP request. This cache is stored in gin.Context and automatically cleaned up when the request completes.

Types

type RequestCache

type RequestCache struct {
	// contains filtered or unexported fields
}

RequestCache provides request-scoped caching to eliminate duplicate database calls within a single HTTP request. Cache is automatically cleared when the request completes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL