Changeset 19380 for lang/php

Show
Ignore:
Timestamp:
09/16/08 21:07:17 (2 months ago)
Author:
cocoiti
Message:

putint, getintを追加したなぜかこっちだけリトルエンディアンな謎

Location:
lang/php/Net_TokyoTyrant/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lang/php/Net_TokyoTyrant/trunk/Net/TokyoTyrant.php

    r19373 r19380  
    251251        return $this->_getInt4(); 
    252252    } 
    253     
     253   
     254    public function putint($key, $num) 
     255    { 
     256        $value = pack('V', $num); 
     257        return $this->put($key, $value); 
     258    } 
     259   
     260    public function getint($key) 
     261    { 
     262        $data = $this->get($key); 
     263        if ($data === false) { 
     264            return false; 
     265        } 
     266        $value =  unpack('V', $data); 
     267        return $value[1]; 
     268    } 
     269 
    254270    public function adddouble($key, $integ, $fract) 
    255271    { 
  • lang/php/Net_TokyoTyrant/trunk/tests/tmp_test.php

    r19373 r19380  
    6767assert($tt->addint($count_key, 2) === 3); 
    6868assert($tt->addint($count_key, -2) === 1); 
     69assert($tt->putint($count_key, 1)); 
     70assert($tt->getint($count_key) === 1); 
     71assert($tt->addint($count_key, 1) === 2); 
     72assert($tt->getint($count_key) === 2); 
     73assert($tt->addint($count_key, -3) === -1); 
    6974 
    7075