API Ecommerce uses Laravel’sDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/JuanSCaicedo/Api-Ecommerce/llms.txt
Use this file to discover all available pages before exploring further.
Cache facade to cache the responses of read-heavy storefront endpoints. By wrapping expensive database queries inside Cache::remember(), repeated requests for the same data are served directly from the cache store without hitting MySQL. The default cache driver is file (responses are stored as serialised files on disk), but Redis is strongly recommended for any non-trivial deployment.
Cached endpoints
The following TTL constants are defined inHomeController:
| Endpoint | Cache key | TTL | Notes |
|---|---|---|---|
GET /api/ecommerce/home | home_response_{Y-m-d_H} | 2592000 s (30 days) | Key rotates every hour; a new key is generated at the start of each clock hour, causing the first request of each hour to rebuild the cache |
GET /api/ecommerce/menu | menu_response_{Y-m-d} | 86400 s (24 hours) | Key rotates daily at midnight |
GET /api/ecommerce/product/{slug} | product_{slug}_{campaing} | 2592000 s (30 days) | {campaing} is the value of the campaing_discount query parameter, or no_discount if omitted |
| Flash discount products | discount_flash_products | 2592000 s (30 days) | Collection of products belonging to the active type-2 flash discount campaign |
| Discount flash campaign | discount_flash | 2592000 s (30 days) | The active flash discount model itself |
| Principal sliders | sliders_principal | 2592000 s (30 days) | type_slider = 1 |
| Secondary sliders | sliders_secundario | 2592000 s (30 days) | type_slider = 2 |
| Product sliders | sliders_products | 2592000 s (30 days) | type_slider = 3 |
| Random categories (home) | categories_randoms | 2592000 s (30 days) | 5 randomly selected active top-level categories |
| Menu categories | menu_categories | 86400 s (24 hours) | Nested category tree used by the storefront navigation |
| Product sections (trending, featured, etc.) | products_{section} | 2592000 s (30 days) | One key per section: products_trending_new, products_trending_featured, products_trending_top_sellers, products_last_discounts, products_last_featured, products_last_selling, electronics, carusel |
| Related products | related_products_{product_id} | 2592000 s (30 days) | Cached per product |
| Maintenance status | maintenance_status | 300 s (5 minutes) | Boolean — whether vista_mantenimiento is active. Short TTL so maintenance mode changes propagate within 5 minutes |
home and show_product endpoints wrap the entire response object — including nested collections — in a single Cache::remember() call:
Cache invalidation
API Ecommerce uses a flush-on-write strategy: every admin or storefront write operation that could affect cached storefront data callsCache::flush() to clear the entire cache store. This guarantees consistency at the cost of a cold cache after each write.
Cache::flush() is called inline in admin controllers after each write, and via the clearAllProductCaches() private helper in SaleController, ReviewController, and AuthController:
| Operation | Controller | Invalidation method |
|---|---|---|
| Product create | Admin\Product\ProductController::store | Cache::flush() |
| Product update | Admin\Product\ProductController::update | Cache::flush() |
| Product delete | Admin\Product\ProductController::destroy | Cache::flush() |
| Product image delete | Admin\Product\ProductController::delete_imagen | Cache::flush() |
| Slider create / update / delete | Admin\SliderController | Cache::flush() |
| Discount create / update / delete | Admin\Discount\DiscountController | Cache::flush() |
| Coupon create / update | Admin\Cupone\CuponeController::store, ::update | Cache::flush() |
| Home view update | Admin\HomeViewController::update | Cache::flush() |
| User profile update | AuthController::update | Cache::flush() via clearAllProductCaches() |
| Review create / update | Ecommerce\ReviewController | Cache::flush() via clearAllProductCaches() |
| Checkout (direct payment) | Ecommerce\SaleController::store | Cache::flush() via clearAllProductCaches() |
| Checkout (MercadoPago) | Ecommerce\SaleController::checkout_mercadopago | Cache::flush() via clearAllProductCaches() |
CuponeController::destroy does not call Cache::flush(). Deleting a coupon will not invalidate cached storefront responses that may reference the deleted coupon. HomeViewController::store and HomeViewController::destroy are currently unimplemented stubs and do not flush the cache either.Configuring the cache driver
By default Laravel uses thefile driver. Add the following variables to your .env file to switch to Redis:
predis/predis or phpredis extension is installed before switching drivers. After changing the driver, run: