Looking at the documentation you can put an object (Map> is an object) and hence we can use complex types as well .
You can definitely put map> into the Org Cache
Apex code
public class OrgCacheController {
// Constructor of the controller for the Visualforce page.
public OrgCacheController() {
}
// Adds various values to the cache.
// This method is called when the Visualforce page loads.
public void init() {
Map <Id,List<Contact>> mapAccIdByCntlst = new Map <Id,List<Contact>> ();
for (Contact c: [Select Id, name, AccountId from Contact limit 1000]) {
// AccountId mapping with Contact List
if (mapAccIdByCntlst.containsKey(c.AccountId)) {
mapAccIdByCntlst.get(c.AccountId).add(c); //tricky part .Here map.get(key) is returning list and we are adding contacts to the list
} else {
List < Contact > lstcnts = new List < Contact > (); //Initialize list as no key is found before and first time we get key
lstcnts.add(c);
mapAccIdByCntlst.put(c.AccountId, lstcnts);
}
}
if (!Cache.Org.contains('maplist')) {
Cache.Org.put('maplist', mapAccIdByCntlst );
}
}
// Return output from the cache.
public Map<Id,List<Contact>> getOutput() {
return (Map<Id,List<Contact>>)Cache.Org.get('maplist');
}
}
VF class
<apex:page controller="OrgCacheController" action="{!init}">
<apex:form >
<br/>Partition display
<apex:repeat value="{!Output}" var="fieldKey">
<apex:outputText value="{!fieldKey}"/>:
{!Output[fieldKey]}<br/>
</apex:repeat>
</apex:form>