RE: [coldbox:18545] Re: ColdBox 3.6 - JDBC Cache Error on Railo, no issue on ACF

Ok, I gave it a quick try and it seems to work great. Here’s my JDBC subclass and my custom marshaller, both of which I placed in my “model” folder

Here is a snippet from my CacheBox.cfc config:

JDBCTest = {
provider = “coldbox.system.cache.providers.CacheBoxColdBoxProvider”,
properties = {
objectStore = “model.myJDBCStore”,
dsn = ‘test’,
table = ‘JDBCStore’
}
}

And here is my code using it:

myCache = cacheBox.getCache(“JDBCTest”);
myCache.set(“foobar”,{test= “foo”, random= [1,2,3,‘a’,‘b’], fubar={key=“value”,key2=“value2”}});
writeDump(myCache.get(“foobar”));
abort;

myJDBCStore.cfc:

component extends=“coldbox.system.cache.store.JDBCStore” {

public myJDBCStore function init(cacheProvider) {
super.init(arguments.cacheProvider);

instance.converter = createObject(“component”,“model.JSONMarshaller”).init();

return this;
}

}

JSONMarshaller.cfc

component {

public JSONMarshaller function init() {
return this;
}

public any function serializeObject(any target) {
return SerializeJSON(arguments.target);
}

// Leave argument name “binaryObject”-- passed by named-argument
public any function deserializeObject(any required binaryObject) {
return DeserializeJSON(arguments.binaryObject);
}

}

The value is stored in the database as:
{“TEST”:“foo”,“RANDOM”:[1,2,3,“a”,“b”],“FUBAR”:{“KEY2”:“value2”,“KEY”:“value”}}

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com