When my app loads I need to establish the membership "status" of a user. Their "status" will determine how the app behaves. Do I query the database for the "status" value each time the app loads, or can it be sourced from cache? The "status" could change for a user, not not very often. Thanks.

Your app always needs to "phone home" to query the actual member status with your server.

Otherwise, someone could log in twice, delete their account in one session and merrily carry on using their 'account' in the other session.

Sure, you could use the cached version if the user is just browsing, but as soon as they attempt some 'membership required' step, you need to verify membership at that point.

The membership status of users does not change frequently, so it is prudent to use a cache to achieve optimal performance. Load the status from the cache on app startup to reduce database queries and improve response times. Implement a cache expiration policy or a mechanism to invalidate the cache when a user's status changes, thereby ensuring that the data is accurate. This approach balances speed and data integrity.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.