Platform Cache Usage

The platform cache is temporary cache and a performance-optimization technique.
Divided into Org Cache and Session Cache.
Here I used Session Cache which is cache space for an individual user session.
Our Organization(Unlimited Edition) has 30MB free by Default. I allocated 5MB for session Cache and used it.
Setup Platform Cache:
Setup--> Develop-->Platform Cache


How do we use this session Cache?

Example:

When you don't want to pass the variable in URL .You can use Platform cache.


Code:

  public with sharing class testClass {
  public String test{get;set;}

     public PageReference download(){    
        if (test!= null){
          Cache.Session.put('test', test);
   }
}

public with sharing class testClass2{
    public string link; 

    //Get the Link from Session Cache 
    public testClass2(){
        link = (String)Cache.Session.get('test');   
  }
}
P.S: Comment Below for any Clarification or help!!


Happy working!! :) :)

Comments

Popular posts from this blog

Embed Special Characters in VF Page

Error: Compile Error: Illegal conversion from String to System.PageReference

Some Common Errors in the Visual flow