zoukankan      html  css  js  c++  java
  • Memcache使用

     
    //需要下载memcache 服务 然后 在命令里面 安装和启动服务
    //引用 Memcached.ClientLibrary.dll
    public class MemcacheHelper { public static readonly MemcachedClient mc = null; static MemcacheHelper() { string[] serverlist = { "127.0.0.1:11211", "10.0.0.132:11211" };//放在配置文件. //初始化池 SockIOPool pool = SockIOPool.GetInstance(); pool.SetServers(serverlist); pool.InitConnections = 3; pool.MinConnections = 3; pool.MaxConnections = 5; pool.SocketConnectTimeout = 1000; pool.SocketTimeout = 3000; pool.MaintenanceSleep = 30; pool.Failover = true; pool.Nagle = false; pool.Initialize(); // 获得客户端实例 mc = new MemcachedClient(); mc.EnableCompression = false; } public static void Set(string key, object value) { mc.Set(key, value); } public static void Set(string key, object value, DateTime time) { mc.Set(key, value, time); } public static object Get(string key) { return mc.Get(key); } public static bool Delete(string key) { if (mc.KeyExists(key)) { mc.Delete(key); return true; } return false; } }
  • 相关阅读:
    前端
    小程序开发
    mpvue开发小程序
    (33)Vue购物车
    Vue的使用你学会了吗?
    (32)Vue模板语法
    (31)Vue安装
    (3)Angular的开发
    (2)Angular的开发
    (1)Angular的开发
  • 原文地址:https://www.cnblogs.com/zengpeng/p/5685422.html
Copyright © 2011-2022 走看看