Using Appery.io In Memory Data (Cache) to Make Your App Run Faster
Want to make your app run faster? The Appery.io Database allows In Memory Data storage. Try using Appery.io in-memory to significantly improve performance.
Join the DZone community and get the full member experience.Join For Free
With Appery.io Database (part of Backend Services) you can store any app data. The database is instantly exposed via REST APIs to retrieve, create and search data. The database comes with out-of-the-box user management, files collection, and devices collection to send targeted push messages.
Appery.io offers another place to store data called: In Memory Data (IMD). This is basically a very fast cache where you can store data for a limited amount of time. Accessing this cache is about 10 times faster than accessing the database. Any data data in cache will be automatically removed after 20 minutes so you don’t need to worry about clearing the cache.
When working with data that doesn’t need to be persisted for a long time, you want to use this storage because it is very fast. For example, let’s say you generate a code that the user has to enter to confirm his/her account. Such code usually has a limited life span, so you can use In Memory Data to store it there. Another example if you need Server Code scripts to share data. Any script can access this data fast (think of this as very fast local storage with limited time for scripts).
The IMD uses key/pair and has a very simple API that allows you to add, lookup and remove data from the cache. The API is part of Server Code. Below is an example inserting, checking the size and deleting items from the cache.
// save IMD.put("confirmCode", "123456789"); // check size console.log("after insert: " + IMD.length()); // result 1 // delete IMD.remove("confirmCode"); // check size again console.log("after delete: " + IMD.length()); // result 0
You can learn more about the IMD API here.
Using this cache is simple and you get a very fast access to data. Any Server Code script is Build a Mobile App with Custom API Backend in 5 Minutes that you can use in in a mobile app.
Published at DZone with permission of Max Katz, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.