User Manual

Fetch From Cache

Fetch From Cache

The Fetch From Cache action is used to retrieve data previously added to the cache using Push To Cache. This allows the application to quickly access previously stored data and improve performance. Supported cache providers are Redis, Mongo, SQL, and Memory, and each is managed through the Configuration Manager.

This action can be used in both web and mobile applications. For Redis usage, users can provide their own connection strings and retrieve data from the cache through their own instances. When InMemory is selected, data is only accessible while the application is running and is deleted when the application is closed.

This action can be used in both web and mobile applications.

Technical Specifications

  • Key (String - Required): Unique key that identifies the data to be retrieved from the cache. Must have been added previously with Push To Cache.
  • Output (Any - Required): Variable or field to which the retrieved data will be assigned. This field can be used in other actions or screen components.
  • Override Behavior: If a new value is added via Push To Cache with the same key, Fetch From Cache always returns the most recent value.

Fetch From Cache Action Steps

  1. Action Definition
    • Open your project on the Kuika platform.
  • Click the Add Action button on the right side and select the Fetch From Cache action.
  1. Specify Cache Key
  • Select from the menu of keys previously added with Push To Cache.
  • Example: user_123_filters
  1. Use Cache Provider
    • The cache provider must be the same as the data saved with Push To Cache (InMemory, Redis, Mongo, or SQL). If it is not the same, it can be changed in the Cache Settings area of the Configuration Manager module.
    • Example: Redis in the web application, InMemory in the mobile application.
  2. Executing and Testing the Action
    • Run the action in Preview mode.
    • Verify that the correct data is returned in the Output variable.
    • If you are using Redis, you can check the cache by running the redis-cli -h localhost -p 6379 command in the terminal.
  3. Important Points
    • Fetch From Cache can only retrieve keys that were previously added with Push To Cache.
    • The cache provider must be the same as Push To Cache; otherwise, the data cannot be retrieved.
    • When InMemory is selected, the data is deleted when the application is closed.

Use Case: Quick Access to E-Commerce Product Filters

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

  1. 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
  2. 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.
  3. 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)
  4. 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.
  5. 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.

Fetch From Cache Action Advanced Customizations

  • Conditional Fetch: Data can be fetched based on specific user roles or screen states.
  • Data Type Check: JSON, String, or Number type data is returned correctly.
  • Fallback Values: If the key cannot be found, a default value can be assigned.

Technical Risks

  • Invalid Key: If a key that has not been added before is selected, the action returns a “Key not found” error.
  • Type Mismatch: If the output variable and the data type in the cache do not match, unexpected errors may occur.
  • Cache Provider Mismatch: If a different provider is used with Push To Cache, data cannot be retrieved.
  • InMemory Limits: In-memory cache data is lost when the application is closed.
  • Concurrent Update: If data is added to the same key simultaneously, Fetch From Cache always returns the latest value.
  • Beta Risks: Some behaviors related to Redis or other providers may differ in test and preview environments.

Other Related Content

No items found.

Glossary

No items found.

Alt Başlıklar