package main import ( "common" "fmt" "proto" "strconv" "time" "github.com/garyburd/redigo/redis" "github.com/gogo/protobuf/proto" ) type RedisHelper struct { redisClient *redis.Pool } v…
package main import ( "fmt" ) type TeamBase struct { m_TeamId uint64 m_Rid uint32 m_RoomRule uint32 m_Players []uint64 } type TeamInt interface { Init() CreateTeam(accountId uint64, rid uint32) bool AddTeamPlayer(accountId uint64) bool DelTeamPl…
package main import ( "fmt" "reflect" ) type order struct { ordId int customerId int } func createQuery(q interface{}) { t := reflect.TypeOf(q) //----NB啊 if t.String() == "main.order" { fmt.Println("Type ", t) fmt.P…
package main import ( "fmt" "sync" ) var l sync.Mutex var a string func f() { a = "hello, world" l.Unlock() } //还是需要加锁的!!! type testClass struct { mutex sync.Mutex x []byte } func (this *testClass) init() { this.x = make([]by…
Go语言之从0到1实现一个简单的Redis连接池 前言 最近学习了一些Go语言开发相关内容,但是苦于手头没有可以练手的项目,学的时候理解不清楚,学过容易忘. 结合之前组内分享时学到的Redis相关知识,以及Redis Protocol文档,就想着自己造个轮子练练手. 这次我把目标放在了Redis client implemented with Go,使用原生Go语言和TCP实现一个简单的Redis连接池和协议解析,以此来让自己入门Go语言,并加深理解和记忆.(这样做直接导致的后果是,最近写JS时…
  目录 Redis 连接池的问题    1 1.    前言    1 2.解决方法    1     前言 问题描述:Redis跑了一段时间之后,出现了以下异常. Redis Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use.  …
红眼技术博客 » redis连接池 redis连接池…
/** * @类描述 redis 工具 * @功能名 POJO * @author zxf * @date 2014年11月25日 */public final class RedisUtil { private static JedisPool jedisPool = null; /** * 初始化Redis连接池 */ static { try { //加载redis配置文件 ResourceBundle bundle = ResourceBundle.getBundle("redis&qu…
redis作为缓存型数据库,越来越受到大家的欢迎,这里简单介绍一下java如何操作redis. 1.java连接redis java通过需要jedis的jar包获取Jedis连接. jedis-2.8.0.jar public void getConn() { //获取jedis连接 Jedis jedis = new Jedis("127.0.0.1",6379); //获取redis中以FIELD开头的key Set<String> keys = jedis.keys(…
单机模式: package com.ljq.utils; import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisPool; import redis.clients.jedis.JedisPoolConfig; /** * Redis操作接口 * * @author NiceCui * @version 1.0 2017-6-14 上午08:54:14 */ public class RedisAPI { privat…