@@ -10,7 +10,6 @@ import (
1010 "context"
1111 "fmt"
1212 "io"
13- "log"
1413 "mime/multipart"
1514 "net/http"
1615 "strconv"
@@ -45,7 +44,6 @@ type image struct {
4544 imageService * service.ImageService
4645 workerPool * worker.Pool
4746 batchProc * batch.BatchProcessor
48- cache service.CacheService
4947}
5048
5149// ImageProcessRequest represents an image processing request
@@ -80,7 +78,7 @@ type BatchDeleteRequest struct {
8078 AWSDelete bool `json:"aws_delete"`
8179}
8280
83- func NewImage (minioClient * minio.Client , awsService service.AwsService , imageService * service.ImageService , cacheService service. CacheService ) Image {
81+ func NewImage (minioClient * minio.Client , awsService service.AwsService , imageService * service.ImageService ) Image {
8482 // Initialize worker pool with 5 workers
8583 workerConfig := worker .DefaultConfig ()
8684 workerConfig .Workers = 5
@@ -92,7 +90,6 @@ func NewImage(minioClient *minio.Client, awsService service.AwsService, imageSer
9290 awsService : awsService ,
9391 imageService : imageService ,
9492 workerPool : wp ,
95- cache : cacheService ,
9693 }
9794
9895 // Initialize batch processor with default config
@@ -102,12 +99,6 @@ func NewImage(minioClient *minio.Client, awsService service.AwsService, imageSer
10299 bp := batch .NewBatchProcessor (batchConfig , img .processBatch )
103100 bp .Start ()
104101
105- // Initialize cache service
106- cacheService , err := service .NewCacheService ()
107- if err != nil {
108- log .Printf ("Failed to initialize cache service: %v" , err )
109- }
110- img .cache = cacheService
111102 img .batchProc = bp
112103
113104 return img
@@ -127,15 +118,6 @@ func (i image) GetImage(c *fiber.Ctx) error {
127118 resize , width , height = service .GetWidthAndHeight (c , service .QueryType )
128119 }
129120
130- // Try to get from cache if resize is requested and cache service is available
131- if resize && i .cache != nil {
132- if cachedImage , err := i .cache .GetResizedImage (bucket , objectName , width , height ); err == nil {
133- c .Set ("Content-Type" , http .DetectContentType (cachedImage ))
134- return c .Send (cachedImage )
135- }
136- }
137-
138- // Continue with normal flow if not in cache
139121 if found , err := i .minioClient .BucketExists (ctx , bucket ); ! found || err != nil {
140122 return c .SendFile ("./public/notfound.png" )
141123 }
@@ -159,16 +141,11 @@ func (i image) GetImage(c *fiber.Ctx) error {
159141
160142 if resize {
161143 resizedImage := i .imageService .ImagickResize (getByte , width , height )
162- // Cache the resized image if cache service is available
163- if i .cache != nil {
164- if err := i .cache .SetResizedImage (bucket , objectName , width , height , resizedImage ); err != nil {
165- log .Printf ("Failed to cache resized image: %v" , err )
166- }
167- }
144+ c .Status (http .StatusOK )
168145 return c .Send (resizedImage )
169146 }
170147
171- c .Status (http .StatusFound )
148+ c .Status (http .StatusOK )
172149 return c .Send (getByte )
173150}
174151
0 commit comments