Redis中使用设置值后到客户端取不到值

时间:2025-03-12 09:16:16
  • package ;
  • import ;
  • import ;
  • import org.;
  • import org.;
  • import ;
  • import ;
  • import ;
  • import ;
  • import ;
  • import ;
  • import .junit4.SpringJUnit4ClassRunner;
  • @RunWith(value = )
  • @ContextConfiguration(classes = {})
  • public class RedisTemplateTest {
  • private static final Logger logger = ();
  • @Autowired
  • RedisTemplate redisTemplate;
  • @SuppressWarnings("unchecked")
  • @Test
  • public void testRedisTemplate() throws ClassNotFoundException {
  • @SuppressWarnings("rawtypes")
  • SessionCallback<Object> sessionCallback = new SessionCallback() {
  • @Override
  • public Object execute(RedisOperations operations) throws DataAccessException {
  • int count = 0;
  • while (count < 1000) {
  • ().set("keyTest", "valueTest" + count);
  • count++;
  • ("count:{}", ().get("keyTest"));
  • }
  • return null;
  • }
  • };
  • (sessionCallback);
  • // List<RedisClientInfo> list = ().getConnection().getClientList();
  • // for (RedisClientInfo redisClientInfo : list) {
  • // ("getDatabaseId:{}", ());
  • // }
  • // ().set("keyTest", (88888888));
  • // ("redis_db:{}", ((Jedis)().getConnection().getNativeConnection()).getDB());
  • }
  • }
  • 相关文章