일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- jpa
- write by GPT-4
- kotlin
- 파이썬
- 데이터베이스
- spring data jpa
- 코틀린
- write by chatGPT
- Database
- JVM
- 유닉스
- NIO
- 자바
- 인프라
- oracle
- 시스템
- flet
- 고전역학
- android
- GPT-4's answer
- 역학
- Java
- python
- 소프트웨어공학
- 리눅스
- 자바암호
- 자바네트워크
- spring integration
- 웹 크롤링
- chatGPT's answer
- Today
- Total
기억을 지배하는 기록
sscache : SHOP.COM Cache System 본문
sscache : SHOP.COM Cache System
"SHOP.COM"이라는 영국 쇼핑몰 사이트에서 사용중인 Object Cache API을 Open Source로 제공하고 있습니다. 최신 버전은 0.3 버전은 2008년 12월 19일 쯤에 등록이 되었습니다. 간략한 테스트를 해보고 느낀 점을 정리 해봤습니다.
순수 Java 개발
CacheServer을 실행하고 Client가 TCP/IP로 접속하는 방식
CacheServer에서 Object 저장에 File DB을 사용하고 Data File과 Index File 2개가 생성 됨
Serializable 을 상속 받은 Object 만 저장 가능. Serializable을 상속 받지 않는 Object을 저장 하려 할경우 Error을 발생하지 않고 File DB에도 저장되지 않는다. 이게 버그인지 사용을 잘못한것인지 출력 로그가 없어 확인 불가능
CacheServer가 구동되지 않은 상태에서 Cache를 사용하려 해도 클라이언트에 오류가 출력되지 않는다. 마치 정상 동작하는 것 처럼 보이지만 실제 CacheServer에 Object는 저장되지 않음.
Multi-CacheServer 사용 가능
CacheServer을 Handling 할 수 있는 API가 너무 부족함.
"SHOP.COM" 사이트에서는 많은 서버에 Application과 ChachServer을 설치해 사용하고 있으며, 각 서버 사양은 Windows 64bit OS에 8GB 메모리라고 합니다.
DownLoad Site
http://code.google.com/p/sccache/
Sample Code
CacheServer
package com.naver.blog.inter999.sccache; import java.io.File; import java.io.IOException; import com.shop.cache.api.server.SCServer; import com.shop.cache.api.server.SCServerContext; import com.shop.cache.api.server.SCServerFactory; import com.shop.cache.api.storage.SCStorage; import com.shop.cache.imp.common.ShopComCacheFactory; import com.shop.cache.imp.storage.ccdb2.CCDB2Parameters; import com.shop.cache.imp.storage.ccdb2.CCDB2StorageFactory; public class CacheServer { public static void main(String[] args) throws Exception { try { SCServerFactory factory = ShopComCacheFactory.getServerFactory(); SCServerContext context = factory.newContext(); context.port(1111); <- 서비스 Port SCStorage db = CCDB2StorageFactory.create(new CCDB2Parameters()); db.open(new File("C:/DownLoad")); <- File DB 생성 위치 SCServer server = factory.newServer(context, db); server.join(); } catch (IOException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } } } |
CacheClient
package com.naver.blog.inter999.sccache; import java.net.InetSocketAddress; import com.shop.cache.api.client.io.SCClientContext; import com.shop.cache.api.client.io.SCClientFactory; import com.shop.cache.api.client.io.SCClientManager; import com.shop.cache.api.client.main.SCCache; import com.shop.cache.api.client.main.SCDataBlock; import com.shop.cache.imp.common.ShopComCacheFactory; public class CacheClient { public static void main(String[] args) throws Exception { SCClientFactory clientFactory = ShopComCacheFactory.getClientFactory(); SCClientContext context = clientFactory.newContext(); context.address(new InetSocketAddress("192.168.13.76", 1111)); <- Server IP, Port SCClientManager manager = clientFactory.newClientManager(context); SCCache myCache = new SCCache(manager); String myKey = System.currentTimeMillis()+""; MyObject obj = new MyObject(); obj.setName("Hurukku"); obj.setAddress("SEOUL"); obj.setAge(16); myCache.put(new SCDataBlock(myKey, obj)); String myKey2 = System.currentTimeMillis()+500+""; obj = new MyObject(); obj.setName("Hurukku2"); obj.setAddress("SEOUL2"); obj.setAge(16); myCache.put(new SCDataBlock(myKey2, obj)); System.out.println(myCache.getConnectionList()); System.out.println((MyObject)myCache.get(new SCDataBlock(myKey))); System.out.println((MyObject)myCache.get(new SCDataBlock(myKey2))); } } |
MyObject
package com.naver.blog.inter999.sccache; import java.io.Serializable; public class MyObject implements Serializable { private static final long serialVersionUID = 20081223L; private String name; private int age; private String address; private String phone; public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } public String getPhone() { return phone; } public void setPhone(String phone) { this.phone = phone; } public String toString() { return "name : "+name+", address : "+address+", age : "+age; } } |
Test
1. 설치한 sccachhe의 lib 폴더 밑에 있는 모든 Jar 파일을 Class Path에 추가합니다.
2. CacheServer 실행
- CacheServer가 실행되면 지정된 File DB 폴더에 33MB 정도의 .db 파일이 생성됩니다.
3. CacheClient 실행
[2 client(s), 1. 192.168.13.76 - listclients, 2. 192.168.13.76 - put]
name : Hurukku, address : SEOUL, age : 16
name : Hurukku2, address : SEOUL2, age : 16
- CacheClient가 실행되고 나면 File DB 폴더에 16MB 정도의 .idx Index 파일이 생성됩니다.
'오래된글 > Java' 카테고리의 다른 글
Dependency Injection in Java EE 6 - Part 2 (0) | 2018.04.19 |
---|---|
Dependency Injection in Java EE 6 - Part 1 (0) | 2018.04.19 |
Sampling & Testing JUnit (0) | 2018.04.09 |
Reqular Expression in XML (0) | 2018.04.09 |
Powerful Fluent Interfaces is Now Easier than Ever: op4j 1.0 Released (0) | 2018.04.09 |