I’m back with another question around scaling hori...
# lucee
d
I’m back with another question around scaling horizontally. Thanks to folks here, we think we have sessions saving to an external Redis cache. We’re looking at query caching now. We are mainly just using
cachedWithin
, specifying a tag, and then busting the
cacheClear
here and there using that tag. Am I understanding it correctly that I can’t use the same cache for both sessions and queries? If not, can I set up the same Redis host with multiple names in the Application.cfc (RedisSession, RedisQuery, etc.) or is that a bad idea?
Our current query cache in the Application.cfc is just something like this, very generic…
Copy code
this.cache.connections[ 'QueryCache' ] = {
		'class'   : 'org.lucee.extension.cache.eh.EHCache',
		'storage' : true,
		'custom'  : {
			'bootstrapAsynchronously'               : 'true',
			'replicatePuts'                         : 'true',
			'automatic_hostName'                    : '',
			'bootstrapType'                         : 'on',
			'maxelementsinmemory'                   : '10000',
			'manual_rmiUrls'                        : '',
			'distributed'                           : 'off',
			'automatic_multicastGroupAddress'       : '230.0.0.1',
			'memoryevictionpolicy'                  : 'LRU',
			'replicatePutsViaCopy'                  : 'true',
			'timeToIdleSeconds'                     : '86400',
			'maximumChunkSizeBytes'                 : '5000000',
			'automatic_multicastGroupPort'          : '4446',
			'listener_socketTimeoutMillis'          : '120000',
			'timeToLiveSeconds'                     : '86400',
			'diskpersistent'                        : 'true',
			'manual_addional'                       : '',
			'replicateRemovals'                     : 'true',
			'replicateUpdatesViaCopy'               : 'true',
			'automatic_addional'                    : '',
			'overflowtodisk'                        : 'true',
			'replicateAsynchronously'               : 'true',
			'maxelementsondisk'                     : '10000000',
			'listener_remoteObjectPort'             : '',
			'asynchronousReplicationIntervalMillis' : '1000',
			'listener_hostName'                     : '',
			'replicateUpdates'                      : 'true',
			'manual_hostName'                       : '',
			'automatic_timeToLive'                  : 'unrestricted',
			'listener_port'                         : ''
		},
		'default' : 'query'
	};
Here is our Redis cache connection in the Application.cfc that is working for sessions.
Copy code
this.cache.connections[ 'redis' ] = {
	'class'         : 'lucee.extension.io.cache.redis.simple.RedisCache',
	'bundleName'    : 'redis.extension',
	'bundleVersion' : '3.0.0.51',
	'storage'       : true,
	'custom'        : {
		'secretKey'         : '',
		'minIdle'           : '0',
		'secretName'        : '',
		'maxTotal'          : '24',
		'maxIdle'           : '8',
		'maxLowPriority'    : '0',
		'host'              : redisHost,
		'accessKeyId'       : '',
		'password'          : '',
		'idleTimeout'       : '300000',
		'liveTimeout'       : '3600000',
		'region'            : '',
		'port'              : redisPort,
		'timeToLiveSeconds' : '0',
		'socketTimeout'     : '2000',
		'username'          : '',
		'connectionTimeout' : '5000'
	},
	'default' : ''
};
Wait…is it as easy as adding
query
to the
default
parameter in the redis connection info? Can the same cache work for sessions and query then?
If so, how do you make sure a query being cached won’t kick out a user’s session?
In the EHCache, I see stuff like
'memoryevictionpolicy'                  : 'LRU',
that I don’t see in the Redis options. Hmm.
b
I'm pretty sure the same cache can be re-used for both sessions and query caching
d
Yeah, looks like you’re correct. We changed that default to the name of our redis cache and I can see new non-session stuff getting plopped there now. Cool!
I can’t edit posts here, so I’ll correct my verbiage by saying if I put the default of
default : 'query'
in the redis connection, it is used for queries as well. We can then reference it by name when doing stuff like cacheClear().