redis-client
2021-06-01 02:00:05 0 举报
jedis,jedis-pool,lettuce三种redis-client的详解
作者其他创作
大纲/内容
StatefulRedisConnectionImpl
# final RedisCodec codec;# final RedisCommands sync;# final RedisAsyncCommandsImpl async;# final RedisReactiveCommandsImpl reactive;
RedisCommand dispatch(RedisCommand command)
Connection
RedisClient
- RedisURI redisURI;
+ StatefulConnection connect();+ StatefulConnection connectPubSub();
AbstractRedisClient
+ ClientOptions getOptions();+ ClientResources getResources();+ void addListener(RedisConnectionStateListener listener);+ void addListener(CommandListener listener);
send binary msg by BIO socket
RedisChannelWriter
RedisCommand write(RedisCommand command);void flushCommands();ClientResources getClientResources();
org.apache.commons.pool2
BinaryClient
# Client client; // include a socket client# Transaction transaction;# Pipeline pipeline;- final byte[][] dummyArray = new byte[0][];
+ exists(final byte[]... keys);+ del(final byte[]... keys);+ flushDB();
sendRedisCommand
doSendRedisCommand
factory create new object success then return the unwraped object
borrowObject
Client
create a wraped object
PushHandler
void addListener(PushListener listener);void removeListener(PushListener listener);Collection<PushListener> getPushListeners();
VALIDATION
no attr
DefaultPooledObject
- boolean isInMulti;- String user;- String password;- int db;- boolean isInWatch;
transfer to binary command call the internal net client
send binary resp recieved by socket
RETURN
工厂创建
GenericObjectPool
getFromIdleDeque
PooledObjectFactory
RedisChannelHandler
final RedisChannelWriter channelWriter;final ClientResources clientResources;
返回容器
ClientResources
ClientResources create();ClientResources create(ThreadFactoryProvider threadFactoryProvider)Builder builder();
使用完成
redisOperation
+ T borrowObject();+ void returnObject(T obj)...
makeObject
ABANDONED
user recive the redis resp result
INVALID
ALLOCATED
doRedisOperation
IDLE
getInternalObj
user call the jedis api
return the redis-server resp
容器中
get unwraped resource object
JedisPoolAbstract
+ void returnBrokenResource(Jedis resource);+ void returnResource(Jedis resource);
Endpoint
void initialState();
Pool
# GenericObjectPool<T> internalPool;
socket resp
Jedis
PooledObject<T> makeObject() ;void destroyObject(PooledObject<T> var1);boolean validateObject(PooledObject<T> var1);void activateObject(PooledObject<T> var1);void passivateObject(PooledObject<T> var1);
DefaultClientResources
- EventLoopGroupProvider eventLoopGroupProvider;- final ThreadFactoryProvider threadFactoryProvider;- final SocketAddressResolver socketAddressResolver;- final EventExecutorGroup eventExecutorGroup;final EventLoopGroupProvider eventLoopGroupProvider;
+ int ioThreadPoolSize();
DefaultEndpoint
# volatile Channel channel;- final ClientOptions clientOptions;- final ClientResources clientResources;- final Queue<RedisCommand> disconnectedBuffer;- final Queue<RedisCommand> commandBuffer;- final SharedLock sharedLock;- ConnectionFacade connectionFacade;
call the factory make new object
user call the get resource api
redis.client.jedis
return unwraped object
transfer to readable charset
- JedisSocketFactory jedisSocketFactory;- Socket socket;- RedisOutputStream outputStream;- RedisInputStream inputStream;- boolean broken = false;
- final T object;- PooledObjectState state;- final long createTime;- volatile long lastBorrowTime;- volatile long lastUseTime;- volatile long lastReturnTime;- volatile boolean logAbandoned;- volatile CallStack borrowedBy;- volatile CallStack usedBy;- volatile long borrowedCount;
+ synchronized boolean allocate();+ synchronized boolean deallocate()
JedisPool
ConnectionFacade
void activated();void deactivated();void reset();
+ void returnBrokenResource(Jedis resource);+ void returnResource(Jedis resource);+ Jedis getResource();
sendCommand
getResource
收藏
0 条评论
下一页