Wednesday, July 30, 2014

I Just wanted get the Redis Manage Tools on windows like sqldeveloper

I found good manage tool for redis on windows 

this show us datas and be able to use console like redis-cli


I think I just prepare to enjoy redis

Tuesday, July 29, 2014

Redis java client Jedis

It is very easy to use

I just follow sample code

and output is excellent ~!!

Jedis jedis = new Jedis("localhost");
jedis.set("foo", "bar");
String value = jedis.get("foo");


and if you access to multithread enviroment follow this article

Basic usage example

using Jedis in a multithreaded environment

You shouldn't use the same instance from different threads because you'll have strange errors. And sometimes creating lots of Jedis instances is not good enough because it means lots of sockets and connections, which leads to strange errors as well. A single Jedis instance is not threadsafe! To avoid these problems, you should use JedisPool, which is a threadsafe pool of network connections. You can use the pool to reliably create several Jedis instances, given you return the Jedis instance to the pool when done. This way you can overcome those strange errors and achieve great performance.
To use it, init a pool:
JedisPool pool = new JedisPool(new JedisPoolConfig(), "localhost");
You can store the pool somewhere statically, it is thread-safe.
JedisPoolConfig includes a number of helpful Redis-specific connection pooling defaults. For example, Jedis with JedisPoolConfig will close a connection after 300 seconds if it has not been returned.
You use it by:

Jedis jedis = pool.getResource();
try {
  /// ... do stuff here ... for example
  jedis.set("foo", "bar");
  String foobar = jedis.get("foo");
  jedis.zadd("sose", 0, "car"); jedis.zadd("sose", 0, "bike"); 
  Set<String> sose = jedis.zrange("sose", 0, -1);
} finally {
  /// ... it's time to release alive/broken Jedis instance...
  if (null != jedis) {
/// ... when closing your application:

Redis installation

1. download redis latest file from

make install

           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 2.8.13 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in stand alone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 26766
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |         
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           

[26766] 30 Jul 09:35:14.823 # Server started, Redis version 2.8.13
[26766] 30 Jul 09:35:14.824 * The server is now ready to accept connections on port 6379

open different console


redis simple command

############## Expire ###########

-- 입력 -- 
set resource:lock "redis demo"    

-- 시간 타임 --
expire resource:lock 120
 - return 1 정상적으로 적용

-- 얼마나 남았는지 확인 --
ttl resource:lock 113 

113 second left

############ List ##############

command : rpush, lpush, llen, lrange, lpop, rpop

rpush  puts the new value at the end of the list 
-> rpush friends "alice" 

plush puts the new value at the start of the list
-> plush friends "sam"

large gives a subset of the list it takes the index of the first element you what to retrieve as its first parameter and the index of the last element you what to retrieve as tis second parameter. A value of -1 for the second parameter means to retrieve elements until the end of the list.
-> lrange friends 0 -1  (All)
-> lrange friends 0 1
-> lrange friends 1 2  

llen returns the current length of the list.
-> llen friends 

lpop removes the first element from the list and return it
-> lpop friends 

rpop removes the last element from the list and returns it
-> rpop friends 

이거는 java 에서 set 과 얼추 비슷한다.
하나의 set에는 동일한 데이터가 들어갈 수 없다.

############ SET #################

SADD adds the given value to the set.

    SADD superpowers "flight"
    SADD superpowers "x-ray vision"
    SADD superpowers "reflexes"
SREM removes the given value from the set.

SREM superpowers "reflexes" 

SISMEMBER tests if the given value is in the set. It returns 1 if the value is there and 0 if it is not.

    SISMEMBER superpowers "flight" => 1
    SISMEMBER superpowers "reflexes" => 0
SMEMBERS returns a list of all the members of this set.

    SMEMBERS superpowers => 1) "flight", 2) "x-ray vision"
SUNION combines two or more sets and returns the list of all elements.

    SADD birdpowers "pecking"
    SADD birdpowers "flight"
    SUNION superpowers birdpowers => 1) "pecking", 2) "x-ray vision", 3) "flight"

######## HASH ##########

Hashes are maps between string fields and string values, so they are the perfect data type to represent objects (eg: A User with a number of fields like name, surname, age, and so forth):

    HSET user:1000 name "John Smith"
    HSET user:1000 email ""
    HSET user:1000 password "s3cret"
To get back the saved data use HGETALL:

    HGETALL user:1000
You can also set multiple fields at once:

    HMSET user:1001 name "Mary Jones" password "hidden" email ""
If you only need a single field value that is possible as well:

    HGET user:1001 name => "Mary Jones"

Numerical values in hash fields are handled exactly the same as in simple strings and there are operations to increment this value in an atomic way.

    HSET user:1000 visits 10
    HINCRBY user:1000 visits 1 => 11
    HINCRBY user:1000 visits 10 => 21
    HDEL user:1000 visits
    HINCRBY user:1000 visits 1 => 1

Check the full list of Hash commands for more information.

Redis start

I don't exactly know why I want to know Redis

the point of redis is memory cache and key-value store

i will deeply study of it and will use for better computer program

Friday, July 25, 2014

make service what is not stopping

I recommend this post is really good to restart service after stopping.

and there are two ways~! read it

Thursday, July 3, 2014

javascript get parameters function

usually we want to parse data from url

this is good function ~

I'm not sure because I didn't test in all cases

so that use it before fully test

function  getQueryParams (url) {
var params = {};
var parameters = (url.slice(url.indexOf('?') + 1, url.length))
for (var i = 0; i < parameters.length; i++) {
var param = parameters[i].split('=');
params[param[0]] = param[1];
return params;

Share site for checking function to use or not

Today I introduce

Wednesday, July 2, 2014

This is what I parsing in html tags

today I had to parse html tag and replace ~!

document.querySelector('.mailInfo') : query if document has the tag defined mailInfo in class

table. querySelectorAll('tr') : this will return array of tr object elements

table.getAttribute('summary') :  this will return value if summary attribute exist

This is Example

function bigMailInit(){
// 메일 인포를 찾음...
var mailInfo = document.querySelector('.mailInfo');
var li = mailInfo.querySelectorAll('table');
// 널 체크, just in case
if(li == null || li.length ==0){
var i=0;
var table;
// 메일 인포안에 여러개의 테이블이 있지만 대용량 테이블이 아닐수도 있어서 Summary attribute에서 체크 해야함
for(i=0; i<li.length; i++){
table = li[i];
var summary = table.getAttribute('summary');
if(summary != null){
if(summary.indexOf('대용량') >= 0 && summary.indexOf('Mass') >= 0 ){
var tbody= table.querySelectorAll('tbody');
if(tbody[0].children.length <3){
var start =3; // tr의 3번째부터 첨부파일들이 나열
for(start; start<tbody[0].children.length; start++){
a = tbody[0].children[start].querySelectorAll('a');
var j=0;
for(j; j<a.length; j++){
a[j].href = a[j].getAttribute('href');