Migrating to Transfer 1.3 - TransferORM/transfer GitHub Wiki
Unless you were previously running the pluggable_cache branch from the RIAForge subversion repo, you will probably need to make some minor changes to your configuration to use Transfer 1.3+ from GitHub. Otherwise, you will see an error like:
The XML Provided in 'C:/webroot/sitename/config/transfer.xml' is not valid against its XML Schema:
[Error] :5:34: cvc-complex-type.2.4.a: Invalid content was found starting with element 'maxobjects'.
One of '{setting}' is expected. [Error] :8:28: cvc-enumeration-valid: Value 'instance' is not
facet-valid with respect to enumeration '[string, numeric, boolean, date, UUID, GUID, binary]'.
It must be a value from the enumeration. [Error] :8:28: cvc-attribute.3:
The value 'instance' of attribute 'type' on element 'scope' is not valid with respect to its type, 'null'.
The migration process is very simple. For default installations of Transfer, you will need to change a couple of lines in transfer.xml and create a new ehcache.xml file using the default below.
You will need to replace your current settings with a new baseline:
<objectCache>
<defaultcache provider="transfer.com.cache.provider.EHCacheProvider">
<setting name="config" value="path/to/ehcache.xml" />
</defaultcache>
</objectCache>
To disable caching for a particular package.object, you can add a child to
<cache provider="transfer.com.cache.provider.NoCacheProvider" class="package.object" />
Start with the following ehcache configuration, which specifies up to 1000 objects may be kept in memory (per class) with an idle time of 120 seconds and a max time to live of 900 seconds:
<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd">
<defaultCache
maxElementsInMemory="1000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="900"
overflowToDisk="false"
/>
</ehcache>
Ehcache.xml is a standard ehcache configuration file which can accept any valid configuration setting. Your previous Transfer settings map to the ehCache like so:
- accessedminutestimeout => timeToIdleSeconds
- maxminutespersisted => timeToLiveSeconds
maxElementsInMemory caps the total number of objects of a single class that may be stored in memory. If you have 50 objects with a limit of 1000, that means you can have 50,000 total!
If you specify eternal = true, then timeouts are ignored and the only thing that will cause an object to be discarded from the cache is the maxElementsInMemory limit.
Here are examples from my application (running on EhCache now for 4 years):
<objectCache>
<defaultcache provider="transfer.com.cache.provider.EHCacheProvider">
<setting name="config" value="/transfer/ehcache.xml" />
</defaultcache>
<cache class="system.audit" provider="transfer.com.cache.provider.NoCacheProvider" />
<cache class="mail.deliveryfailure" provider="transfer.com.cache.provider.NoCacheProvider" />
<cache class="mail.subscription" provider="transfer.com.cache.provider.NoCacheProvider" />
</objectCache>
And some ehcache.xml variations:
<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd">
<defaultCache
maxElementsInMemory="350"
eternal="true"
overflowToDisk="false"
/>
<!-- eternal for big objects -->
<cache name="event.event" maxElementsInMemory="750" eternal="true" overflowToDisk="false" />
<cache name="event.eventtype" maxElementsInMemory="50" eternal="true" overflowToDisk="false" />
<!-- fine tune away from the defaults -->
<cache name="member.member" maxElementsInMemory="500" eternal="true" overflowToDisk="false" />
<cache name="member.vehicle" maxElementsInMemory="1000" eternal="true" overflowToDisk="false" />
<cache name="event.class" maxElementsInMemory="75" eternal="true" overflowToDisk="false" />
<cache name="event.group" maxElementsInMemory="75" eternal="true" overflowToDisk="false" />
<!-- short lived, eternal = false with ttl -->
<cache name="user.user" maxElementsInMemory="500" timeToIdleSeconds="900" eternal="false" overflowToDisk="false" />
<cache name="user.role" maxElementsInMemory="750" timeToIdleSeconds="900" eternal="false" overflowToDisk="false" />
</ehcache>