I am new for Salesforce/Apex programming. I am working on Community application. In my requirement I need to get some application level configuration data. I am using Custom Object to store my application level configuration. To get application level configuration data I am doing query and getting data from SalesForce with every request/flow.
I like to know that SalesForce community/Apex application support Application Context like concept so that I can store all of my application level data into it and use same to get application level data (I don’t like to query DB for every request/flow).
also like to know suggestion for following solution/flow
1. Create a singletone object to store Application level configuration data.
2. Upload Application data at the time of application installation.
3. Store all Application level data into Map.
4. Use SinleTone object to manipulate data (Update data in the table as well as in SinleTone Map).
Basically, you need "Custom Settings." They come in two flavors: "list" and "hierarchy". List configurations are ideal for storing lists of values, such as those that would apply to an entire organization, for example. The hierarchy type supports saving global, per profile, and per user configuration settings, such as which fields to display, email preferences, etc.
In both cases, custom settings are stored in the application cache. This cache can be accessed without queries, and can be "protected" against modification from outside your code. There is a limit to how much data can be cached, although this is generally not a problem for all but the largest of organizations.
You can initialize some default values on installation using an InstallHandler script. Typically, most developers build one or more Visualforce pages to allow a graphical configuration of the settings. Keep in mind though, that unlike ASP's "Application" object, which is a collection of static variables across one instance of a server, custom settings are accessible to all users in the organization at once, and are committed/saved in the same mannerism as normal database records.
In this sense, custom settings are more powerful than the Application object of a traditional server, because they are available to all users without any special syntax, even though salesforce.com is load-balanced across clusters of application servers.
Setup > Develop > Custom Settings
Note that once you specify the type (list or hierarchy), it is locked in as that type. If there can only ever be one instance, consider a hierarchy (use only the org default value).
Settings can be configured using the InstallHandler interface. This lets you set default values directly from code on installation.
For lists, you access the values with CustomSetting__c.getInstance(string), where CustomSetting__c is the API name of the custom setting. There's no need for a map, per se, because it's immediately available from the cache. For hierarchy settings, CustomSetting__c.getOrgDefaults() will return the default values.
CustomSetting__c.getOrgDefaults() is a singleton; only one instance of this value will exist in the cache at once. This is handled for you automatically, so there's no need to try and write a custom singleton. As an aside, all variables in salesforce.com are isolated by transaction, so there's no concept as a static variable that exists across all users currently using the system; custom settings are the closest approximation to this concept.