Xano Documentation
  • 👋Welcome to Xano!
  • 🌟Frequently Asked Questions
  • 🔐Security & Compliance (Trust Center)
  • 🙏Feature Requests
  • 💔Known Issues
  • Before You Begin
    • Using These Docs
    • Where should I start?
    • Set Up a Free Xano Account
    • Key Concepts
    • The Development Life Cycle
    • Navigating Xano
    • Plans & Pricing
  • The Database
    • Designing your Database
    • Database Basics
      • Using the Xano Database
      • Field Types
      • Relationships
      • Database Views
      • Export and Sharing
      • Data Sources
    • Migrating your Data
      • Airtable to Xano
      • Supabase to Xano
      • CSV Import & Export
    • Database Performance and Maintenance
      • Storage
      • Indexing
      • Maintenance
      • Schema Versioning
  • 🛠️The Function Stack
    • Building with Visual Development
      • APIs
        • Swagger (OpenAPI Documentation)
      • Custom Functions
        • Async Functions
      • Background Tasks
      • Triggers
      • Middleware
      • Configuring Expressions
      • Working with Data
    • Functions
      • AI Tools
      • Database Requests
        • Query All Records
          • External Filtering Examples
        • Get Record
        • Add Record
        • Edit Record
        • Add or Edit Record
        • Patch Record
        • Delete Record
        • Bulk Operations
        • Database Transaction
        • External Database Query
        • Direct Database Query
        • Get Database Schema
      • Data Manipulation
        • Create Variable
        • Update Variable
        • Conditional
        • Switch
        • Loops
        • Math
        • Arrays
        • Objects
        • Text
      • Security
      • APIs & Lambdas
        • Realtime Functions
        • External API Request
        • Lambda Functions
      • Data Caching (Redis)
      • Custom Functions
      • Utility Functions
      • File Storage
      • Cloud Services
    • Filters
      • Manipulation
      • Math
      • Timestamp
      • Text
      • Array
      • Transform
      • Conversion
      • Comparison
      • Security
    • Data Types
      • Text
      • Expression
      • Array
      • Object
      • Integer
      • Decimal
      • Boolean
      • Timestamp
      • Null
    • Environment Variables
    • Additional Features
      • Response Caching
  • Testing and Debugging
    • Testing and Debugging Function Stacks
    • Unit Tests
    • Test Suites
  • CI/CD
  • File Storage
    • File Storage in Xano
    • Private File Storage
  • Realtime
    • Realtime in Xano
    • Channel Permissions
    • Realtime in Webflow
  • Maintenance, Monitoring, and Logging
    • Statement Explorer
    • Request History
    • Instance Dashboard
      • Memory Usage
  • Building Backend Features
    • User Authentication & User Data
      • Separating User Data
      • Restricting Access (RBAC)
      • OAuth (SSO)
    • Webhooks
    • Messaging
    • Emails
    • Custom Report Generation
    • Fuzzy Search
    • Chatbots
  • Xano Features
    • Snippets
    • Instance Settings
      • Release Track Preferences
      • Static IP (Outgoing)
      • Change Server Region
      • Direct Database Connector
      • Backup and Restore
      • Security Policy
    • Advanced Back-end Features
      • Xano Link
      • Developer API (Deprecated)
    • Metadata API
      • Master Metadata API
      • Tables and Schema
      • Content
      • Search
      • File
      • Request History
      • Workspace Import and Export
      • Token Scopes Reference
  • Xano AI
    • Building a Backend Using AI
    • Get Started Assistant
    • AI Database Assistant
    • AI Lambda Assistant
    • AI SQL Assistant
    • API Request Assistant
    • Template Engine
    • Streaming APIs
  • AI Tools
    • MCP Servers
      • Connecting Clients
      • MCP Functions
  • Xano Transform
    • Using Xano Transform
  • Xano Actions
    • What are Actions?
    • Browse Actions
  • Team Collaboration
    • Realtime Collaboration
    • Managing Team Members
    • Branching & Merging
    • Role-based Access Control (RBAC)
  • Agencies
    • Xano for Agencies
    • Agency Features
      • Agency Dashboard
      • Client Invite
      • Transfer Ownership
      • Agency Profile
      • Commission
      • Private Marketplace
  • Enterprise
    • Xano for Enterprise
    • Enterprise Features
      • Microservices
      • Tenant Center
      • Compliance Center
      • Security Policy
      • Instance Activity
      • Deployment
      • RBAC (Role-based Access Control)
      • Xano Link
  • Your Xano Account
    • Account Page
    • Billing
    • Referrals & Commissions
  • Troubleshooting & Support
    • Error Reference
    • Troubleshooting Performance
      • When a single workflow feels slow
      • When everything feels slow
      • RAM Usage
      • Function Stack Performance
    • Getting Help
      • Granting Access
      • Community Code of Conduct
      • Community Content Modification Policy
  • Special Pricing
    • Students & Education
    • Non-Profits
  • Security
    • Best Practices
Powered by GitBook
On this page
  • What is Data Caching?
  • How long can I store data in the Data Cache?
  • Caching Functions
  • Set a Cache Value
  • Get a Cache Value
  • Has a Cache Value
  • Delete Cache Value
  • Increment Cache Value
  • Decrement Cache Value
  • Get Cache Keys
  • Add to Beginning of List
  • Add to End of List
  • Remove from Beginning of List
  • Remove from End of List
  • Remove from List
  • Get Length of List
  • Get Elements from List
  • Rate Limit

Was this helpful?

  1. The Function Stack
  2. Functions

Data Caching (Redis)

What is Data Caching?

Xano provides a data caching service, powered by Redis, that allows you to temporarily store data in memory for high-performance data retrieval and storage purposes. This is great for storing temporary data that needs to be quickly generated and accessed for a period of time.

If you are retrieving data from a database or an external API, for example, that you know never, or very infrequently, changes, using data caching can be incredibly valuable.

How long can I store data in the Data Cache?

Through the cache functions you use, you can manually set how long data gets stored, or you can expect it to naturally get overwritten once it reaches the 100MB limit.

Note

As mentioned above, Data Caching is temporary storage - so never store something that can't be recovered - if permanent storage is required, then the database can and should be used.

Caching Functions

Set a Cache Value

Redis Cache Values work in key-value pairs. Set a Cache Value function allows you to define a key to reference the cache value in other cache functions. The data input is where you define the data you wish to be cached (the value of the pair). Ttl stands for time to live. Set this, in seconds, to determine how long to cache the data for.

Key: define a key name to reference the cache value by.

Data: select the value that you wish to cache. This will often be a variable containing data.

TTL: define how long, in seconds, for the cache to last. After this time expires, the query will run normally again and reset the data cache value for the specified time. Set this equal to 0 never reset the cache value.

Redis is extremely sensitive to data variation, so you may find it useful to store JSON objects as text strings for easier use of additional caching functions, such as 'removing from list'.

Get a Cache Value

Get a Cache Value allows you to retrieve a cache value based on the defined key of a set cache value. Get a Cache Value function also outputs a variable so that you can use the data from the cache value in other functions or in the response.

Key: enter in the key of a set cache value that you wish to retrieve.

Has a Cache Value

Has a Cache Value allows you to determine whether or not a cache value exists based on the key. This function will return a boolean of true or false as a variable depending on if the cache value exists.

Key: enter a key to find if a cache value exists.

The return variable result will look like this:

Because the key "user_info" has a cache value, the return variable is true.

Delete Cache Value

Delete cache value will delete a cache value based on the key of the cache value.

Key: enter in the key of a set cache value in order to delete it.

If we try to Get Cache Value for the same key after it is deleted, the response will come back as false.

In this example, we are doing a Get Cache Value for the same key that is being deleted in the prior step. We will try to return the return variable of the Get Cache Value.

The Get Cache Value returned a result of false because the cache value was already deleted.

Increment Cache Value

Increment Cache Value allows you create an Incremental Cache Value by choosing a key and choosing the value to increment by. The incremented value is returned in a variable so you can perform logic based on what the count is.

Key: set a key name.

By: choose the value to increment by.

Increment Cache Value can act as a lightweight counter. The incremental values are stored on temporary memory, so keep in mind, if the server were to ever restart then the count would be reset.

Use case examples include a promotion where something is available or accessible for the first 100 users. Or perhaps, the 100th user wins the promotion.

Decrement Cache Value

Decrement Cache Value allows you to decrement a cache value by choosing a key and a value to decrement it by. The decremented cache value is returned in a variable so you can perform additional logic based on its value.

Key: create a key name for the decrement cache value.

By: choose the value to decrement by.

Decrement cache value is similar to increment cache value but it decreases the value. You can also use this as a counter stored on temporary memory.

Get Cache Keys

Get Cache Keys allows you to retrieve cache keys that match a searched value. You can use "*" as a wildcard to search. Only putting in "*" will grab all keys but you can combine it with with text string to narrow your search.

Search: enter in they name of the keys you are searching for. Use "*" as a wildcard.

Here's an example of combining the wildcard "*" with text to retrieve cache key.

Add to Beginning of List

Add to Beginning of List allows you to insert a value at the start of the list stored at a key you specify.

Key: set a key name.

Value: the value to add to the beginning of the list.

Add to End of List

Add to End of List allows you to insert a specified value at the tail end of the list, stored at the key you specify.

Key: set a key name.

Value: the value to add to the end of the list

Remove from Beginning of List

Allows you to remove the first element from a list stored at a key you specify.

Key: the key that you'd like to remove the value from

Remove from End of List

Allows you to remove the last element from a list stored at a key you specify.

Key: the key that you'd like to remove the value from

Remove from List

Allows you to remove a specified item from a list. You can choose to remove all specified values, or a maximum amount.

Key: the key that you'd like to remove the value from

Value: the value you would like to remove

Count: the amount of values you want to remove. The default (0) will remove all, or you can specify a maximum.

Get Length of List

Allows you to return the current length of a list as a variable.

Key: specifies the key you would like to reference

Get Elements from List

Allows you to retrieve a range of values from a list.

Key: specify which key you would like to reference.

Start: identifies the start of the elements you would like to retrieve.

Stop: identifies the end of the elements you would like to retrieve.

You can use negative values to represent the end of the list (ex. -1 is the last element, -2 is the second to last, and so on). The start and stop parameters are also inclusive. This means that the results you are given will include the elements at the positions you start and end with.

Rate Limit

Xano allows you to set rate limits on your queries so that you can limit the requests per given time period that an API endpoint can be called.

The Rate Limit function comes with a few settings for configuration.

Key: define a key for the rate limit.

Max: set the max amount of requests allowed in the given time or TTL.

TTL: set the time to live, in seconds, of each cycle.

Error: optionally include an error message. If you include an error message, when the Rate Limit is reached it will automatically throw an error and display this message. If you do not, the Rate Limit will output a boolean of false when the Rate Limit is reached. This can be used if you wish to create custom logic for what happens when the Rate Limit is reached.

Last updated 3 months ago

Was this helpful?

🛠️