首页 文章 精选 留言 我的

精选列表

搜索[扩展更新],共10011篇文章
优秀的个人博客,低调大师

linux下安装php扩展memcache

memcache 的工作就是在专门的机器的内存里维护一张巨大的hash表,来存储经常被读写的一些数组与文件,从而极大的提高网站的运行效率,减轻后端数据库的读写压力。 实验环境:centos 6.6 x86_64 LAMP环境搭建完毕:php版本5.6.8、apache版本2.4.12 1、在安装memcached之前需要安装libevent支持: 1 2 3 4 5 #wgethttp://syslab.comsenz.com/downloads/linux/libevent-1.4.12-stable.tar.gz #tarzxvflibevent-1.4.12-stable.tar.gz #cdlibevent-1.4.12-stable #./configure--prefix=/usr/local/libevent #make&&makeinstall 2、服务器端 memcached 的编译安装 1 2 3 4 5 #wgethttp://syslab.comsenz.com/downloads/linux/memcached-1.4.5.tar.gz #tarzxvfmemcached-1.4.5.tar.gz #cdmemcached-1.4.5 #./configure--prefix=/usr/local/memcached--with-libevent=/usr/local/libevent/ #make&&makeinstall 3、客户端安装memcache步骤: 1 2 3 4 5 6 #wgethttp://www.lishiming.net/data/attachment/forum/memcache-2.2.3.tgz #tarzxvfmemcache-2.2.3.tgz #cdmemcache-2.2.3 #/usr/local/php/bin/phpize #./configure--with-php-config=/usr/local/php/bin/php-config--enable-memcache #make 执行make后报错如下: 1 2 3 4 5 6 7 8 9 10 11 12 /usr/local/src/memcache-2 .2.3 /memcache .c:在函数‘php_mmc_connect’中: /usr/local/src/memcache-2 .2.3 /memcache .c:1902:错误:提供给函数‘zend_list_insert’的实参太少 /usr/local/src/memcache-2 .2.3 /memcache .c:1919:错误:提供给函数‘zend_list_insert’的实参太少 /usr/local/src/memcache-2 .2.3 /memcache .c:在函数‘zif_memcache_add_server’中: /usr/local/src/memcache-2 .2.3 /memcache .c:1975:错误:提供给函数‘zend_is_callable’的实参太少 /usr/local/src/memcache-2 .2.3 /memcache .c:2003:错误:提供给函数‘zend_list_insert’的实参太少 /usr/local/src/memcache-2 .2.3 /memcache .c:在函数‘zif_memcache_set_server_params’中: /usr/local/src/memcache-2 .2.3 /memcache .c:2059:错误:提供给函数‘zend_is_callable’的实参太少 /usr/local/src/memcache-2 .2.3 /memcache .c:在函数‘mmc_find_persistent’中: /usr/local/src/memcache-2 .2.3 /memcache .c:2159:错误:提供给函数‘zend_list_insert’的实参太少 /usr/local/src/memcache-2 .2.3 /memcache .c:2177:错误:提供给函数‘zend_list_insert’的实参太少 make :***[memcache.lo]错误1 根据错误,进行修改: vi memcache.c 将所有的:zend_list_insert(pool, le_memcache_pool); 改为:zend_list_insert(pool, le_memcache_poolTSRMLS_CC); 将所有的:zend_list_insert(mmc, le_pmemcache); 改为:zend_list_insert(mmc, le_pmemcacheTSRMLS_CC); 讲所有的:if (!zend_is_callable(failure_callback, 0, NULL)) 改为:if (!zend_is_callable(failure_callback, 0, NULL, NULL)) 修改完成后,重新make编译; 1 2 #makeinstall Installingsharedextensions: /usr/local/php/lib/php/extensions/no-debug-zts-20131226/ 安装完成后的memcache.so模块在上面的路径中; # vi /usr/local/php/etc/php.ini 在最后一行添加:extension="memcache.so" 保存退出后,重启apache,使用php -m查看已经安装的memcache模块,或者在浏览器访问phpinfo.php查看; 启动memcached服务端: # /usr/local/memcached/bin/memcached -d -u root -m 256 -p 11211 -l localhost -d 是启动一个守护进程, -m 后边指定memecached使用多少内存,单位是M -p 指定memcached 启动端口 -l 指定绑定的IP -u 指定以某个账户的身份启动 启动后报错,找不到libevent模块; /usr/local/memcached/bin/memcached: error while loading shared libraries:libevent-1.4.so.2: cannot open shared object file: No such file or directory 需要把 libevent-1.4.so.2 拷贝或链接到 /usr/lib64 (x86_64位系统,32位的为/usr/lib目录)中,否则 memcached 无法正常加载。 # cp /usr/local/libevent/lib/libevent-1.4.so.2 /usr/lib64 memcache环境测试,写一个php文件,在网站根目录下 1 2 3 4 5 6 7 [root@localhosthtdocs] #cat1.php <?php $mem=newMemcache; $mem->connect( "localhost" ,11211); $mem-> set ( 'test' , 'helloworld' ,0,60); echo $mem->get( 'test' ); ?> 使用curl或者网页访问IP/1.php如果显示hello world 说明配置成功。 1 2 #curl-xlocalhost:80192.168.4.231/1.php helloworld 本文转自 模范生 51CTO博客,原文链接:http://blog.51cto.com/mofansheng/1676746,如需转载请自行联系原作者

优秀的个人博客,低调大师

弹出式菜单扩展学习

看其它应用软件时使用了很多的弹出菜单,蛮好的,顺带学习了下,写了个小DEMO,里面穿插的讲了下系统级的dialog使用小巧门,希望与大家交流学习。。下面来看代码: packagecom.xiaoma.popupmenu.demo; importandroid.app.Activity; importandroid.app.Dialog; importandroid.app.ProgressDialog; importandroid.os.Bundle; importandroid.util.Log; importandroid.view.MenuInflater; importandroid.view.MenuItem; importandroid.view.View; importandroid.view.View.OnClickListener; importandroid.widget.Button; importandroid.widget.PopupMenu; importandroid.widget.Toast; importandroid.widget.PopupMenu.OnMenuItemClickListener; /** *@Title:PopupMenuDemoActivity.java *@Packagecom.xiaoma.popupmenu.demo *@Description:弹出式菜单测试类 *@authorMZH */ publicclassPopupMenuDemoActivityextendsActivityimplementsOnClickListener,OnMenuItemClickListener{ privateButtonshow; /**Calledwhentheactivityisfirstcreated.*/ @Override publicvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.main); init(); } /* *初始化实现 */ privatevoidinit(){ show=(Button)findViewById(R.id.button1); show.setOnClickListener(this); } /* *添加监听器(non-Javadoc) *@seeandroid.view.View.OnClickListener#onClick(android.view.View) */ @Override publicvoidonClick(Viewv){ if(v.getId()==R.id.button1){ showPopup(v); } } /* *弹出对话框实现 */ privatevoidshowPopup(Viewv){ PopupMenupopup=newPopupMenu(getApplicationContext(),v); popup.setOnMenuItemClickListener(this); MenuInflaterinflater=popup.getMenuInflater(); inflater.inflate(R.menu.menutest,popup.getMenu()); popup.show(); } /* *给选择的项添加监听器(non-Javadoc) */ @Override publicbooleanonMenuItemClick(MenuItemitem){ switch(item.getItemId()){ caseR.id.new_game: Log.i("KKK","奇怪"); ShowDialog(item.getTitle()); break; caseR.id.help: ShowDialog(item.getTitle()); break; caseR.id.file: ShowDialog(item.getTitle()); break; caseR.id.create_new: ShowDialog(item.getTitle()); break; caseR.id.open: ShowDialog(item.getTitle()); break; default: break; } returnfalse; } /* *弹出消息方法实现 *因为安卓系统中也自带这样一个临时弹出dialog的方法 *showDialog(intid),所以小马在此处违背了下一般的命名 *规则,起名:ShowDialog(),下面顺带讲下系统自带的临时dialog的实现 */ privatevoidShowDialog(CharSequencech){ Toast.makeText(getApplicationContext(),ch,Toast.LENGTH_SHORT).show(); } /** *在使用系统级自带的showDialog(intid)方法时,必须重载下面这个方法哦 */ @Override protectedDialogonCreateDialog(intid){ ProgressDialogdialog=newProgressDialog(this); dialog.setMessage("小马临时放的字符串一"); returndialog; } /** *在使用系统级自带的showDialog(intid,intid,Bundleargs)方法时, *必须重载下面这个方法 *id:dialog的ID *args为提供给showDialog的第二个方法 */ @Override protectedDialogonCreateDialog(intid,Bundleargs){ ProgressDialogdialog=newProgressDialog(this); dialog.setMessage("小马临时放的字符串二"); returndialog; } } 加载的菜单布局如下: <?xmlversion="1.0"encoding="utf-8"?> <menuxmlns:android="http://schemas.android.com/apk/res/android"> <itemandroid:id="@+id/new_game" android:icon="@drawable/ic_launcher" android:title="新游戏" android:showAsAction="ifRoom"/> <itemandroid:id="@+id/help" android:icon="@drawable/ic_launcher" android:title="帮助"/> <itemandroid:id="@+id/file" android:title="嵌套"> <menu> <itemandroid:id="@+id/create_new" android:title="开始新游戏"/> <itemandroid:id="@+id/open" android:title="开始"/> </menu> </item> <groupandroid:id="@+id/group_delete"> <itemandroid:id="@+id/menu_archive" android:title="组员一"/> <itemandroid:id="@+id/menu_delete" android:title="组员二"/> </group> </menu> 很简单的实现,每天进步一点点,吼吼。。学习再学习!加油。。。 附件:http://down.51cto.com/data/2359943 本文转自华华世界 51CTO博客,原文链接:http://blog.51cto.com/mzh3344258/791569,如需转载请自行联系原作者

优秀的个人博客,低调大师

c#扩展出MapReduce方法

MapReduce方法主体: 1 public static IDictionary<TKey, TResult> MapReduce<TInput, TKey, TValue, TResult>(this IList<TInput> inputList, 2 Func<MapReduceData<TInput>, KeyValueClass<TKey, TValue>> map, Func<TKey, IList<TValue>, TResult> reduce) 3 { 4 object locker = new object(); 5 ConcurrentDictionary<TKey, TResult> result = new ConcurrentDictionary<TKey, TResult>(); 6 //保存map出来的结果 7 ConcurrentDictionary<TKey, IList<TValue>> mapDic = new ConcurrentDictionary<TKey, IList<TValue>>(); 8 var parallelOptions = new ParallelOptions(); 9 parallelOptions.MaxDegreeOfParallelism = Environment.ProcessorCount; 10 //并行map 11 Parallel.For(0, inputList.Count(), parallelOptions, t => 12 { 13 MapReduceData<TInput> data = new MapReduceData<TInput> 14 { 15 Data = inputList[t], 16 Index = t, 17 List = inputList, 18 }; 19 var pair = map(data); 20 if (pair != null && pair.Valid) 21 { 22 //锁住防止并发操作list造成数据缺失 23 lock (locker) 24 { 25 //将匹配出来的结果加入结果集放入字典 26 IList<TValue> list = null; 27 if (mapDic.ContainsKey(pair.Key)) 28 { 29 list = mapDic[pair.Key]; 30 } 31 else 32 { 33 list = new List<TValue>(); 34 mapDic[pair.Key] = list; 35 } 36 list.Add(pair.Value); 37 } 38 } 39 }); 40 41 //并行reduce 42 Parallel.For(0, mapDic.Keys.Count, parallelOptions, t => 43 { 44 KeyValuePair<TKey, IList<TValue>> pair = mapDic.ElementAt(t); 45 result[pair.Key] = reduce(pair.Key, pair.Value); 46 }); 47 return result; 48 } View Code KeyValueClass定义: 1 public class KeyValueClass<K, V> 2 { 3 public KeyValueClass(K key, V value) 4 { 5 Key = key; 6 Value = value; 7 } 8 9 public KeyValueClass() 10 { 11 12 } 13 14 public K Key { get; set; } 15 16 public V Value { get; set; } 17 } View Code Console测试: 1 List<TestClass> listTestClass = new List<TestClass>(); 2 listTestClass.Add(new TestClass { a = "a", g = 1 }); 3 listTestClass.Add(new TestClass { a = "b", g = 3 }); 4 listTestClass.Add(new TestClass { a = "c", g = 4 }); 5 listTestClass.Add(new TestClass { a = "d", g = 2 }); 6 listTestClass.Add(new TestClass { a = "e", g = 1 }); 7 listTestClass.Add(new TestClass { a = "f", g = 2 }); 8 listTestClass.Add(new TestClass { a = "g", g = 5 }); 9 listTestClass.Add(new TestClass { a = "h", g = 6 }); 10 IDictionary<int, string> dic = listTestClass.MapReduce(t => 11 { 12 if (t.g < 5) 13 { 14 return new KeyValueClass<int, string>(t.g, t.a); 15 } 16 return null; 17 }, (key, values) => 18 { 19 return string.Join(",", values); 20 }); View Code TestClass定义: 1 public class TestClass 2 { 3 public string a { get; set; } 4 public string b { get; set; } 5 6 public string d { get; set; } 7 8 //public DateTime f { get; set; } 9 10 public int g { get; set; } 11 12 public List<TestClass> test { get; set; } 13 14 public Dictionary<string, string> dic { get; set; } 15 } View Code 结果: 1:a,e 2:d,f 3:b 4:c 词频性能测试

资源下载

更多资源
腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册