In an e-commerce application, the user saves product filters in advance using Push To Cache. Thanks to the Fetch From Cache action, the filters can be quickly retrieved even if the user changes pages or closes the application for a short time. This scenario improves the user experience and application performance.
Step-by-Step Usage
- User Filter Selection
- The user specifies filters such as brand, color, and price range on the product list page.
- Sample data:
- Brand: Nike
- Color: Red
- Price Range: 500-1000
- Adding Filters to the Cache (Push To Cache)
- When the user clicks the “Apply Filters” button, the filters are saved to the cache with the Push To Cache action.
- Parameters:
- Cache Key: user_123_filters
- The cache provider can be set to Redis for web applications and InMemory for mobile.
- Executing the Fetch From Cache Action
- When the user navigates to another page or opens the filter summary panel, the Fetch From Cache action is triggered.
- Parameters
- Cache Key: user_123_filter
- Output: selectedFilters (variable to which the retrieved data will be assigned)
- Using the Data in the Application
- The Fetch From Cache action assigns the filter data from the cache to the selectedFilters variable.
- The application uses this variable to:
- Automatically populate the filter form fields.
- Apply the filters on the product listing page.
- This way, the filters are preserved even if the user switches pages or closes the application temporarily.
- Testing and Validation
- Web: Use the Redis CLI to run the KEYS * and GET user_123_filters commands to verify that the data is correctly saved and retrieved.
- Mobile: Test in InMemory cache preview mode; verify that the data is lost when the application is closed.