Such memory variable how to do?

Category: Java EE
2011-02-15 07:57:42

Sponsored Links

I have some data is often called
but sometimes people call
twenty-three that I wanted to make this package a package
regularly removed from the database such data exist in memory
program directly from memory, but should be read

such a program is not feasible?
because twenty-three people I frequently read database
database access speed will be greatly reduced
wanted this trick

Sponsored Links

2011-02-15 08:06:37
do static Variables HashTable sysDataCache: Cache
service name String serviceName: the corresponding system parameters identification (key value)
value HashMap dataMap: corresponding system parameter list (taken from a database table)

each load, change the service name serviceName first determine whether the cache sysDataCache,
not in the cache, the data is removed from the table, as dataMap assigned to (serviceName , dataMap) form added to the cache sysDataCache
exists in the cache, then according to the service name to find the corresponding values ​​

principles with the service locator (J2EE design patterns )
2011-02-15 08:19:05
If the query data is the same, it is possible.

big deal to write dead, to be a single-state class, check out beforehand the data already stored.
2011-02-15 08:23:56
concept was good support. Good idea
Domain and server ip had changed since 8/23/2013. Suspend the user registration and posts for program maintenance.