2월, 2013의 게시물 표시

Redis 설치 & 사용

이미지
key-value store 를 찾던중 Redis(http://redis.io/)를 보는데 설치, 사용, 문서가 딱 마음에 든다. 쓰고 싶게 만드는구나. 내가 만들었던 플랫폼들을 보면서 약간의 반성과 교훈을 얻은듯 # 설치 $ wget http://redis.googlecode.com/files/redis-2.6.9.tar.gz $ tar xzf redis-2.6.9.tar.gz $ cd redis-2.6.9 $ make # 서버 실행 $ src/redis-server #클라이언트 실행 $ src/redis-cli redis> set foo bar OK redis> get foo "bar" # 튜토리얼 (10분) http://try.redis.io/ # 튜토리얼 정리 > SET foo bar > GET bar - SETNX (SET-if-not-exists) 키가 없을때만 값을 셋팅 - INCR 키를 자동증가 SET connections 10 INCR connections => 11 INCR connections => 12 DEL connections INCR connections => 1 아래같은 상황을 위해 만든거라고 한다. 1. Client A reads count as 10. 2. Client B reads count as 10. 3. Client A increments 10 and sets count to 11. 4. Client B increments 10 and sets count to 11. 원하는건 12여야 하는데 결과는 11이라는거지. 그런데 이걸 이렇게 구현하나? - EXPIRE, TTL SET resource:lock "Redis Demo" EXPIRE resource:lock 120 // 120초 후에 사라짐 TTL을 이용해 expired time이 얼마 남았는지도 확인

전통?적인 PropertyPlaceholderConfigurer 과 SpEL

전통적인? 방법과 SpEL을 사용해 properties파일 가져오는 방법 1. PropertyPlaceholderConfigurer 사용 2. SpEL 사용 아래 2개로 깔끔하게 처리 - <util:properties id="dataProps" location="classpath:properties/data.properties"> - #{dataProps['redis.host']}