글

RESTful 자바 패턴과 실전 응용: 4장 성능을 고려한 설계

4장 성능을 고려한 설계 Caching String caching header Expire Cache-Control private: 브라우저에서만 캐쉬 가능 public: 브라우저, 프록시, CDN 모두 캐쉬 가능 no-cache: 캐쉬 불가 no-store: 메모리에만 캐쉬 max-age : 리소스 유효 기간 (초) Weak caching header Last-Modified ETag Client -> Server: GET http://api.com/coffee/1234 Client <- Server: 200 OK with ETag "123456789" Client -> Server: GET http://api.com/coffee/1234 with If-None-Match "123456789" Client <- Server 200 OK with new ETag "abcdefghi" (변경된 리소스) 304 Not-Modified (변경되지 않은 경우) Stringly validating ETag match Weakly validating ETag match REST에서 비동기 작업 및 실행 시간이 긴 작업 비동기 요청 응답: 202 Accepted JAX-RS 2.0에 추가된 비동기 인터페이스와 클래스 Server-side AsyncResponse: 주입 가능한 JAX-RS 비동기 응답. 서버 측에서 비동기적으로 응답 처리할 수단 제공 @Suspended: 컨테이너가 HTTP 요청을 다음 스레드에서 처리하도록 지시 CompletionCallback: 요청 처리 완료 시 호출되는 callback ConnectionCallback: 접속과 관련된 비동기 응답의 라이프사이클 이벤트를 받는 비동기 요청 처리 라이프사이클 callback Client-side InvocationCallbac...

[Math] GCD & LCM

GCD(Greatest Common Divisor) & LCM(Least Common Multiple) 1. Find GCD of two number Method 1: use basic Euclidean algorithm. GCD(a, b) = GCD(b%a, a) Method 2: use extended Euclidean algorithm. GCD(a, b) = ax + by Let values of x and y calculated by the recursive call be x 1 and y 1 x = y 1 - ⌊b/a⌋ * x 1 y = x 1 2. Find LCM of two number LCM(a, b) * GCD(a, b) = a * b 3. Reference http://www.geeksforgeeks.org/mathematical-algorithms/#gcd

i++ vs ++i in C and C++

Prefer ++i over i++. In C language, there is no difference between ++i and i++. In C++, ++i has performance gain rather than i++ because of object copy. In detail, refer followings https://stackoverflow.com/questions/24853/what-is-the-difference-between-i-and-i https://stackoverflow.com/questions/24886/is-there-a-performance-difference-between-i-and-i-in-c

Android essentials summary

- Binder Binder is android-specific inter-process communication mechanism and RPC mechanism. Android does not use traditional system V IPC and does use binder, which is efficient and fast. In order to provide efficient IPC, binder driver was added in linux kernel. And for app, AIDL was provided and app developers can develop binder client and server easily without coding the marshalling/unmarshalling stuffs. - ASHMEM Asynchronous shared memory was added to android linux kernel. Compared to system V shared memory, ashmem releases kernel resources when nobody refers the shared memory and kernel can reclaim unpinned shared memory when memory runs low. When app shares large amount of data to other app or service such as surface data and image, passing data by using shared memory does not need to copy data and therefore shared memory outperforms other methods like socket. - AIDL AIDL(Android Interface Definition Language) is a kind of IDL specific to android. AIDL defines programmin...