ARCUS๋ Remote Cache ์์คํ ์ด๋ฏ๋ก ์์ฒญ์ ๋ณด๋ผ ๋ ์ฅ๋น์ ์ฌ์, ๋คํธ์ํฌ ๋ฆฌ์์ค์ ๋ฐ๋ผ ์ง์ฐ ์๊ฐ์ด ๋๋ ค์ง๊ฑฐ๋ ์ฒ๋ฆฌ๊ฐ ๋ถ๊ฐ๋ฅํ ์ํ๊ฐ ๋ฐ์ํ ์ ์๋ค. ๊ทธ๋ฆฌ๊ณ , ์์ฒญ์ ๋ํ ์๋ต์ ๋ฐ์ ๋๋ง๋ค ๋ฐ์ดํฐ๋ฅผ ์๋ก์ด ๊ฐ์ฒด๋ก ๋ณํ์ํค๋ฏ๋ก JVM์ Garbage Collector์ ๋ถ๋ด์ด ๊ฐํด์ง ์ ์๋ค. ๋ฐ๋ผ์ ์ค์ ๋ฐ์ดํฐ๊ฐ ๊ฑฐ์ ๋ณ๊ฒฝ๋์ง ์๊ณ , ๋ณ๊ฒฝ์ด ์๋๋ผ๋ ์์ฃผ ์งง์ ์๊ฐ ๋ด์๋ ์ด์ ๋ฐ์ดํฐ๋ฅผ ๋ณด์ฌ์ค๋ ์๊ด์๋ ๊ฒฝ์ฐ๋ผ๋ฉด Front Cache๋ฅผ ์ฌ์ฉํ ๊ฒ์ ๊ถ์ฅํ๋ค.
ARCUS Java Client์์๋ Transparentํ๊ฒ Front Cache๋ฅผ ํ์ฑํํ ์ ์๋ API๋ฅผ ์ ๊ณตํ์ฌ, Remote Cache์์ Hit์ด ๋์์ ๋ Front Cache์ ๋ฐ์ดํฐ๋ฅผ ๊ธฐ๋กํ๊ฑฐ๋ Front Cache๋ก๋ถํฐ ๋จผ์ ์กฐํ ํ Remote Cache๋ฅผ ์กฐํํ๋ Front cache ๋ก์ง์ ์ง์ ์์ฑํ ํ์๊ฐ ์๋ค.
Arcus Java Client๋ ๋ด๋ถ์ ์ผ๋ก Ehcache3 ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํด ๋ฐ์ดํฐ๋ฅผ ์บ์ฑํ๋ค. ๋ฐ๋ผ์ Front Cache๋ฅผ ์ฌ์ฉํ ๋ ์๋ ๊ทธ๋ฆผ๊ณผ ๊ฐ์ ํํ๋ก ๋ฐ์ดํฐ๋ฅผ ์กฐํํ ์ ์๊ฒ ๋๋ค. ๋ฐ์ดํฐ๋ฅผ ์ ์ฅํ ๋์๋ ARCUS์ Ehcache์ ๋ชจ๋ ์ ์ฅ๋๋ค.
- Transparent Front Cache๋ ํ์ฌ Key-Value get/set์ ๋ํด์๋ง ์ ์ฉ ๊ฐ๋ฅํ๋ค.
- Front cache๋ remote ARCUS์ sync๋ฅผ ๋ง์ถ์ง ์๊ธฐ ๋๋ฌธ์ ์ฃผ๋ก read-only data๋ฅผ cachingํ๋๋ฐ ์ ํฉํ๋ค. ๊ทธ๋ฆฌ๊ณ front caching expire time๋ remote cache entry update์ฃผ๊ธฐ์ ๋ฐ๋ผ sync๊ฐ ๋ง์ง ์๋ ๊ธฐ๊ฐ์ ์ ํ์ ํ์ฌ ์ค์ ํด์ผ ํ๋ค.
- Front Cache์ ์ ์ฅ๋ ๋ฐ์ดํฐ๋ ArcusClient์ flush ๋ฉ์๋๋ฅผ ํตํด flush ๋์ง ์๋๋ค.
- ๋ง์ฝ ํ๋์ ์ ํ๋ฆฌ์ผ์ด์ ์์ ARCUS์ front cache๋ฅผ ์ฌ์ฉํด์ผ ํ๋ ๋ถ๋ถ๊ณผ ์ฌ์ฉํ์ง ์์์ผ ํ๋ ๋ถ๋ถ์ด ๋๋๋ค๋ฉด, ๊ฐ ์ฉ๋์ ๋ง๋ ARCUS client ๊ฐ์ฒด๋ฅผ ๋ณ๋๋ก ์์ฑํด ์ฌ์ฉํด์ผ ํ๋ค.
Front cache๋ฅผ ์ ์ฉํ๋ ค๋ฉด ConnectionFactoryBuilder ๊ฐ์ฒด๋ฅผ ์์ฑํ์ฌ ์๋ ๋ฉ์๋๋ค์ ํธ์ถํ ํ, ArcusClient ๊ฐ์ฒด ์์ฑ์ ์ํ ์ ์ ํฉํ ๋ฆฌ ๋ฉ์๋ ์ธ์๋ก ๋๊ฒจ์ฃผ์ด์ผ ํ๋ค.
-
setMaxFrontCacheElements(int to)(Required)Front Cache์์ ์ฌ์ฉํ ์ต๋ ์์ดํ ๊ฐ์๋ฅผ ์ง์ ํ๋ค. ๊ธฐ๋ณธ๊ฐ์ 0์ด๋ฉฐ Front Cache๋ฅผ ์ฌ์ฉํ์ง ์๋๋ค๋ ๋ป์ด๋ค. ๋ฐ๋ผ์ Front Cache๋ฅผ ์ฌ์ฉํ๊ธฐ ์ํด์๋ ๋ฐ๋์ ์์ ์ ์๊ฐ์ ์ง์ ํด์ผ ํ๋ค. ๋ง์ฝ ์ต๋ Item ์๋ฅผ ์ด๊ณผํ๋ฉด LRU ์๊ณ ๋ฆฌ์ฆ์ ํตํด ๊ฐ์ฅ ์ฌ์ฉ๋์ง ์๋ Item์ ์ ๊ฑฐํ๊ณ ์๋ก์ด Item์ ๋ฑ๋กํ๊ฒ ๋๋ค.
-
setFrontCacheExpireTime(int to)(Optional, default 5)Front Cache item์ expire time์ด๋ค. Front cache๋ item๋ณ expire time์ ์ค์ ํ์ง ์๊ณ , ๋ฑ๋ก๋ ๋ชจ๋ item์ ๋์ผํ expire time์ด ์ ์ฉ๋๋ค. ๊ธฐ๋ณธ๊ฐ์ 5์ด๋ฉฐ ๋จ์๋ second์ด๋ค. ์ค์ ํ์ง ์๋๋ค๋ฉด ๊ธฐ๋ณธ๊ฐ์ ๊ทธ๋๋ก ์ฌ์ฉํ๋ค๋ฉด ๋ฑ๋ก๋ ์ง 5์ด๊ฐ ์ง๋๋ฉด ์๋์ผ๋ก ์ฌ๋ผ์ง๊ฒ ๋๋ค.
์๋๋ Front cache๋ฅผ ์ฌ์ฉํ๊ธฐ ์ํ ์์ ์ฝ๋์ด๋ค. setMaxFrontCacheElements์ 0๋ณด๋ค ํฐ ๊ฐ์ผ๋ก ์ค์ ํ๋ฉด Front Cache๊ฐ ํ์ฑํ๋๋ค. setFrontCacheExpireTime์ ํ์ ์ค์ ์ ์๋์ง๋ง, ์ฌ์ฉ ์ฉ๋์ ๋ง๋๋ก ๋ช ์์ ์ธ ๊ฐ์ ์ค์ ํด ์ฃผ๋ ๊ฒ์ ๊ถ์ฅํ๋ค.
ConnectionFactoryBuilder cfb = new ConnectionFactoryBuilder();
/* Required to use transparent front cache */
cfb.setMaxFrontCacheElements(10000);
/* Optional settings */
cfb.setFrontCacheExpireTime(5);
ArcusClient client = new ArcusClient(SERVICE_CODE, cfb);