对memcache的数据(key-value)进行遍历操作
2012-06-01 20:13
525 查看
1. PHP实现:
参考资料:/article/4962137.html
2. Java实现:
3. Ruby实现:
http://robbin.iteye.com/blog/252345
4. telnet:
http://iamcaihuafeng.blog.sohu.com/159082880.html
特别提醒:http://fnil.net/docs/xmemcached/net/rubyeye/xmemcached/class-use/KeyIterator.html
memcached 1.6.x will remove cachedump stats command,so this method will be removed in the future
参考资料:/article/4962137.html
$port = 11211; $host = '192.168.11.128'; $mem = new Memcache(); $mem->connect($host, $port); $items = $mem->getExtendedStats('items'); $items = $items["$host:$port"]['items']; foreach($items as $key => $values){ $number = $key; $str = $mem->getExtendedStats ("cachedump",$number,0); $line = $str["$host:$port"]; if(is_array($line) && count($line) > 0){ foreach($line as $key => $value) { echo $key . '=>'; print_r($mem->get($key)); echo "\r\n"; } } }
2. Java实现:
import java.io.IOException; import java.net.InetAddress; import java.net.InetSocketAddress; import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; import java.util.concurrent.TimeoutException; import net.rubyeye.xmemcached.KeyIterator; import net.rubyeye.xmemcached.MemcachedClient; import net.rubyeye.xmemcached.XMemcachedClient; import net.rubyeye.xmemcached.exception.MemcachedException; public class XMemcache { public static void main(String[] args) throws IOException, TimeoutException, InterruptedException, MemcachedException { InetAddress addr = InetAddress.getByName("192.168.11.128"); InetSocketAddress ia = new InetSocketAddress(addr, 11211); MemcachedClient client = new XMemcachedClient(ia); KeyIterator it = client.getKeyIterator(ia); while(it.hasNext()) { String key = it.next(); System.out.println(client.get(key)); } client.shutdown(); } }
3. Ruby实现:
http://robbin.iteye.com/blog/252345
4. telnet:
http://iamcaihuafeng.blog.sohu.com/159082880.html
特别提醒:http://fnil.net/docs/xmemcached/net/rubyeye/xmemcached/class-use/KeyIterator.html
memcached 1.6.x will remove cachedump stats command,so this method will be removed in the future
相关文章推荐
- 如何对memcache的数据(key-value)进行遍历操作
- 如何对memcache的数据(key-value)进行遍历操作
- 艾伟:如何对memcache的数据(key-value)进行遍历操作
- 如何对memcache的数据(key-value)进行遍历操作
- 如何对memcache的数据(key-value)进行遍历操作
- 如何对memcache的数据(key-value)进行遍历操作
- 如何对memcache的数据(key-value)进行遍历操作
- [转载]如何对memcache的数据(key-value)进行遍历操作
- 如何对memcache的数据(key-value)进行遍历操作.files
- 如何对memcache的数据(key-value)进行遍历操作
- 如何对memcache的数据(key-value)进行遍历操作
- 如何对memcache的数据(key-value)进行遍历操作
- 对memcache的数据(key-value)进行遍历
- 遍历取出Map集合key-value数据的4种方法
- 程序遍历memcache中的所有key-value
- SQL使用游标遍历多层table获取每行的数据进行操作
- Dictionary<TKey, TValue> 进行where的枚举遍历
- HashMap的遍历效率讨论经常遇到对HashMap中的key和value值对的遍历操作,有如下两种方法:
- 使用SQL游标对数据进行遍历循环操作
- 获取map中根据key进行排序的value数据