java »º´æ¿ò¼Üjava caching systemʹÓÃʾÀý
ҪʹÓÃjava caching system£¬ÐèÒªÏÂÃæÕ⼸¸ö°ü£ºjcs.jar£¬concurrent.jar,commons-logging.jar, commons-lang.jar,commons-collection.jarÕ⼸¸ö°ü£¬ÔÚjava¹¤³ÌÀïÃæ£¬
Ê×ÏÈн¨Ò»¸öʹÓÃjcsµÄÅäÖÃÎļþ£ºcache.ccf£¬ÎļþÃû²»Äܸġ£
# DEFAULT CACHE REGION
# sets the default aux value for any non configured caches
jcs.default=
jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.default.cacheattributes.MaxObjects=2000
jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLifeSeconds=3600
jcs.default.elementattributes.IdleTime=1800
jcs.default.elementattributes.IsSpool=true
jcs.default.elementattributes.IsRemote=true
jcs.default.elementattributes.IsLateral=true
# CACHE REGIONS AVAILABLE
# Regions preconfigured for caching
jcs.region.bookCache=
jcs.region.bookCache.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.region.bookCache.cacheattributes.MaxObjects=1200
jcs.region.bookCache.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
jcs.region.bookCache.elementattributes.IsEternal=false
jcs.region.bookCache.elementattributes.MaxLifeSeconds=7200
jcs.region.bookCache.elementattributes.IdleTime=1800
jcs.region.bookCache.elementattributes.IsSpool=true
jcs.region.bookCache.elementattributes.IsRemote=true
jcs.region.bookCache.elementattributes.IsLateral=true
# AUXILIARY CACHES AVAILABLE
# Primary Disk Cache -- faster than the rest because of memory key storage
jcs.auxiliary.DC=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheFactory
jcs.auxiliary.DC.attributes=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes
jcs.auxiliary.DC.attributes.DiskPath=/usr/opt/bookstore/raf
jcs.auxiliary.DC.attributes.MaxPurgatorySize=10000
jcs.auxiliary.DC.attributes.MaxKeySize=10000
jcs.auxiliary.DC.attributes.OptimizeAtRemoveCount=300000
jcs.auxiliary.DC.attributes.Max
Ïà¹ØÎĵµ£º
JavaµÄException·ÖΪÁ½À࣬һÀàÊÇRuntimeException¼°Æä×ÓÀ࣬ÁíÍâÒ»Àà¾ÍÊÇchecked
Exception¡£JavaÒªÇóº¯Êý¶ÔûÓб»catch´¦ÀíµôµÄchecked
Exception£¬ÐèÒª½«ÆäдÔÚº¯ÊýµÄÉùÃ÷²¿·Ö¡£È»¶ø£¬ÕâÒ»ÒªÇó³£³£¸ø³ÌÐòÔ±´øÀ´Ò»Ð©²»±ØÒªµÄ¸ºµ£¡£
ΪÁ˱ÜÃâÔÚº¯ÊýÉùÃ÷ÖÐдthrows²¿·Ö£¬ÔÚJavaÏîÄ¿ÀïÃæ³£³£¿ÉÒÔ¿´µ½ÒÔÏ´úÂëÓÃÀ´‘Í ......
¶¨Òå:
SingletonģʽÖ÷Òª×÷ÓÃÊDZ£Ö¤ÔÚJavaÓ¦ÓóÌÐòÖУ¬Ò»¸öÀàClassÖ»ÓÐÒ»¸öʵÀý´æÔÚ¡£
Ôںܶà²Ù×÷ÖУ¬±ÈÈ罨Á¢Ä¿Â¼ Êý¾Ý¿âÁ¬½Ó¶¼ÐèÒªÕâÑùµÄµ¥Ï̲߳Ù×÷¡£
»¹ÓÐ, singletonÄܹ»±»×´Ì¬»¯;
ÕâÑù£¬¶à¸öµ¥Ì¬ÀàÔÚÒ»Æð¾Í¿ÉÒÔ×÷Ϊһ¸ö״̬²Ö¿âÒ»ÑùÏòÍâÌṩ·þÎñ£¬±ÈÈ磬ÄãÒªÂÛ̳ÖеÄÌû×Ó¼ÆÊýÆ÷£¬Ã¿´Îä¯ÀÀÒ»´ÎÐèÒª¼ÆÊý£¬µ¥Ì¬ÀàÄÜ·ñ ......
CookieÔÚWebÓ¦ÓóÌÐòÖб»¹ã·º²ÉÓã¬Î¬»¤ä¯ÀÀÆ÷ºÍ·þÎñÆ÷Ö®¼äµÄ״̬¡£Òź¶µÄÊÇÕâÒ»ÌØÐÔÔÚJava
MEƽ̨Öв¢Ã»Óеõ½Ö§³Ö¡£Òò´Ë£¬ÒªÏëά³Ö¿Í»§¶ËºÍ·þÎñÆ÷¶ËµÄ״̬Ôò±ØÐëʹÓÃURLÖØÐ´µÄ·½Ê½¡£URLÖØÐ´²Ù×÷ÆðÀ´±È½ÏÂé·³£¬ËùÒÔÑо¿Ò»ÏÂcookieµÄ
ÔÀí²¢ÔÚJava MEƽ̨ÉÏʵÏÖcookieÊDz»´íµÄ³¢ÊÔ¡£
Ê×ÏÈ£¬ÎÒÃÇÀ´¿´Ò»ÏÂcookieµÄÔÀí¡£µ± ......
public boolean writeXML(String content, String filename)
{
String savepath;
FileOutputStream fout;
// log.info("content:"+content+ ......
ÔÚJavaÖУ¬synchronized¹Ø¼ü×ÖΪ·ÀÖ¹×ÊÔ´³åÍ»ÌṩÁËÖ§³Ö£¬Æä×÷ÓÃÓòÓжþÖÖ£º
ʵÀý·¶Î§¡£
¶ÔÏóʵÀý·¶Î§ÄÚsynchronizedʹÓõÄÁ½ÖÖÐÎʽ£º
ʵÀý·¶Î§Í¬²½·½·¨
publicd class syncTest {
…
synchronized void aMethod() {
//ÐèҪͬ²½Ê¹ÓõĴúÂë
}
}
synchronized aMethod(){}¿ÉÒÔ·ÀÖ¹¶à¸öÏß³Ìͬʱ ......