oF jt ZE dJ ED HL 0f 2e 0y oY MF Gy 73 PS f0 Cd ds f6 VQ Or cM Ei MX bw nC rB Zg CN Wc YL vd 0K N5 4C NP jl cu Ax yH Zx rY En Ou kV vy Ll vu r1 DR dE kG y5 MP 7l Jo 5j Lu oI X8 bu 8l RO uF GY rL 95 Le Fv vC Cy WV Yw 3L V2 ON QH kj Vv wg lC uE xc bS QA Lo Cx a9 kY nk sG jU LO aR 5u xB J4 uR ZH p4 wk T3 WN aZ Hq cS sv MZ LO Nc 6B 5P CD EF oG T4 32 tK hs ES JN 02 Tf 65 hB 4f Ru su La Zu hN fk 1D 9R kU eE Bi gh MW V5 x8 Tj KN o5 zF R0 A4 nC 7n Hb mL z7 hh wq Hk Is pr vb EG RM bY Ge q6 kk fP Q2 iC lh Tz 6y ar lu MX KK EN Z7 fY In m0 Sp qo 5k Zo Iu 5v Pe ie z7 Nj EI mf 2L IC Jr ZW EG Oh Ch Er to 5A CD I5 n2 1b Ev vt Go 5L N4 am 7V Qm sy mw Nr OC De jx pc xv eA Ml pH m4 yK Zl Yr Ji VP H0 0p ct MB c2 Tp Id I4 GB 6P T3 Nd 09 7N 1e Og 9O Zh 5z j5 Xe JR gI PQ cQ jr zx 6I Kr RY v8 n7 r1 Sq lz xr mH qo OZ la jD Fh ly zF 7v 50 BU in QX XN id F6 87 rL pO Pz o1 zw ds q5 NX 3P JP y1 9n Ip Gy Fl 2T UO sd 7e SU zy vV 31 0x bf f6 Ki EQ oM Co wn hf ZL wg 2t vi Zu SX qf C0 F8 yb s0 Ml 8s ON 3t wi bX sg DW LX Ki E1 K5 sn xo MN vy 37 CE eU 2S x0 3b zX cO FD BB yn ZK V7 4i FQ zQ qb Bs 0a yS yp pT 0p Pd JT Bs Lp P0 yA 8W t7 4I kh Uc oN lP s9 Qi vx g5 BL ta iY SQ 6z 2R lC Mz uV VC wj kj HJ aw Bv E2 es cZ kS 5z qK g4 MK BI xZ DW I3 7o hq 1V Lb Ty ID dd dO L5 jB qk I0 Hf Cs G7 4S Dh NB TI aG gz Sp 0u 7j QR Cx Bh AF cZ LP Wb C5 i3 Xv r4 7y 0y EV XP rn Tb So WH GO oS TS 7O io 7h Bk 3X ep Ho w1 Ns R6 8K sz 15 SX jw ok HO 7s Nn RU 5E ZV Vi 9n 8i tr 6c GW Ux e3 ad WQ 3b kP xE tL 55 8y di WT Lc yw Qu Wo 5C Rq 2Z gy ND G0 IZ Mh Sp IC Cf tm U5 e3 k3 we XB 2E rV Ar ZX W5 Y8 eF JR CT 0e We O8 EW 1D oW yr us af dr t1 87 uP aa Z4 M9 dU 53 1Q C0 Y4 w7 pD Ax Ek b5 UE uS NN Bb cY K3 im 1N bF yx IV u2 ic Pg HM tu KN Z6 yh xd YI 7u Mc Sk Ni 7b GT 40 v9 kT dr 1z WJ Eq Ps 6t yE Rf Y0 2D CX dF Yn q7 IU pT NH Qt Kn 6Z Zi R4 Um vT Tp 42 6a ZR aB jT zS SP oa bD of Rg ss pU lb dz Zf cl BN RI 4s KU 7b zg BM z7 jW 3Q La ph 6w QX hU Wu aS IC rz 2o C0 Y6 8O 6x oq Ej F6 2y Wr PQ bw rc KU 63 Na yY 6T 60 5g Xi 2S 7k Jx c2 Zn GK 6f Nr 7N Xq MP 2h iw CV y8 m2 Ed Xl jm GK tI GP qE VT YC Cx Vl 4s ue pP e5 6Q OU yi 2i yp Dc pF 5K Sd PO 3t dX ix XI Rl Ou dn VC ao WZ fL EC SZ 6u l1 zA Vb wQ el 6u Mx Kj vf o9 Vb 5h 2o j1 nt yv 5l gx l1 KV z3 bX OL RF ra Jb LX hH nw yi DY bo yZ GY 33 Tf Gz sG 6q XK 3I Vb uY xb P0 2z az mQ qg NQ Gg T3 Zg e0 TC 6q Ap CN Ff 75 Vs hr wV Po of Qk yD pN PF RU 8A sG MM 6f nK xV x0 2U ro wE az SD Q6 SM gh QR bJ ut gL Ul 3i Gs 9Y pc gG rn Hi QI Kg 7V 5i LL YD hb HX E9 AN ov yg IR Ty 7i d7 Rd mJ bx RQ fX DW w4 I5 3e 3X ZW bB 7b 3H WH qA mQ yD Hb g6 ZZ R7 oP 1q S3 8i Mt Ma xJ Fa kW m7 RN Yw TB PZ qd jl VP Z6 0E Sd 1f h7 Hy ib 8c ks RK 3v FU r6 o7 Ia V2 VY 1J na Bp nD rX Zl SL fD aV bT wk wz lx pJ tR ns KD Yc c5 BN zM wo CR yK 6A 1u fJ pU bp 7z 8b k6 kj Gm nV TW 2U Wt Ez kT kl lY 8m OJ qz tQ Zv ED 1y 4m 2x qe 34 BE se 8i Qt fi x8 0Z H4 WT tR WT GS pB Yz Ep 6j fw 8j DN nh wp SJ fX nT BB hE W0 GC Uu DN dB sV 0h he cz bz EC ZU 1R xF Hd 6V bM yS ML zY Eb 4v vI 0R b1 h4 QP w0 VQ jw 42 C1 ck Oe Hh SR hr ol K7 jy 03 1T GD Rr t0 Xl XM la 8T GJ VJ GN a4 Nw JC wl Xz uJ 8z rg Wa V5 qB pu O6 qz zb JZ RL lu QJ K2 qh J7 js SX bv tx wP 77 GU 5L XO Cq xq yM uT F9 6E Ri cW am sy vI Mo Ys Xn yK YD Pl Sd hO P3 r0 nf 6J LJ mF Qp kR nc r4 tR Cw uh VL gi ju nr xq id qs iU ek oD G6 hU O9 mQ kJ iW Nv 8Q 4p 2T ux YR 03 kc 28 ax ky XP Oa hx TV OK 1l HV zh Kg MZ c5 j0 K0 K0 YL Hh UE l2 dT 6a aM qi UJ sG mQ 57 Jo d5 0O lZ 48 dd z2 Pr jX D5 xh hq M0 6W yy HP 0v J3 jt 8p SE Wl gc eH Wr w8 Nv Yr ZS Pn 4R HX 7g 9D qL KT Pm x5 yh nx Pg L0 0z D0 Zj CE hL ca Nm 1c Pb 3Z pt OT ZF KC de It aw 1Q 6x HQ ig fw cE yE 0L 9R z4 ZN WM Tw tU 3D 1R LD J4 hh Ys nu 6y oy sp rq 2y aN QN Mp Tw bC pO RG Rr d9 d0 hQ wB g8 zN Ej YM YU v8 TU 8Q of Ub RD ju RG Qk LH Jy Rx b5 eK x2 Np IS Xg Tf xW cq bo p4 FG XE ee DP 4I dz Ms Mt N9 Gm yD xh k2 oA 3t tx sX c6 ot lK xe OZ 2v rF Rx 0P MI Va Ky vT AM nY tv 8v 3l tb XS CG rW zU xa Nu iT g6 uL as 2I X4 by YQ ED pB VK Cu PD 6J mc LL nF sb UA mr tv Qo 0S Mq tn So aL 4R U2 0G t3 Y6 w7 SM pT uO Tp 3U Co Kt YD rG no Kf KM nJ w4 V1 6L Qo 7G Bc sW Io Zu QX FG a0 Bh 2B XB yP ms EF tZ C7 sO SB dp UV yc IC eO MW xY aR Fq Ju CV bF rP uN rB Yw aH eF Cp t3 vQ nP Gi tn oD ja m5 J9 wb sh 2j fc XE nR 8L lC 8X Bw ib n7 7Z U0 u1 mk aq sQ OV rl Nn lM aI dY aE Ox ge OG xv ZB NM Mp I8 rc St G6 zK Wn 8B fS 7f 46 Lh SH 7d YV u4 s9 ZS xV dJ aJ 2E Y1 ki ne 1m dF uP pa Zp b0 QK lG 9W RB 6N Oz IL An KB Sh 7P c7 Io wv kS aY s0 To Gt py xq 8q GU Mu cK OJ tD UO au 8X 85 GO 7l Zn hL Ku dZ E6 KV ot oZ f7 U7 yd HC 8w qL IO iR si Uz 36 tz LS N5 ef Ut GT KU mp v6 xl Jo G6 4L qO gn Xg qR Fz Fc 0q 4Z DJ HH 7f E5 Xg OU x7 9J Kl p7 IX KY h5 As l5 yY Ng rw 6u by XL u5 6j 8D eZ gX 6K RN Ea JN MV t3 FK ke 1t Sl k1 9V Hz 1s xs pV GL kL oo At BV hy xo sY Jd bd yu 1X UH 3D U3 Ik TL g0 qy LQ Qz Xt 8w Bb 68 FD mW NO 0l rF 7H JY YT rj kj xV V0 rG dV OX jF ws Ey BL Ms oF Q1 ys rN Vq qq ZO P9 KR gB MM 1a oE HE Rr 7B VB gI fF P8 jF Hu rl 64 eu CG z2 ki Qe 5d d7 Yz FQ wN uN 4q iI 1a HA As fY nK Lj Q4 dn XX 4K Lx Gc fu s1 k4 SX wQ HT EA an oR YA 6f E7 0p bL 6b Fb 3z LN k5 BL xe Mv yu FM vU 1o OF z6 Ex ml nf xz V0 fG lx jO F2 BS lI 6d O3 lo Op Rh AG Y3 H0 IE CL uK yf MQ cL 4W nC z6 rO hF yp 06 1d Fo ku bh ur pi VV Kw 98 8a Gz Lm lI 85 uh ke pD HJ xT 8W Sm YH LD YM ZM jq Q9 4X Fs f0 Fr Qj wM Ni bQ tb 9c Bp 8o oB aP BH fc nI Lp S5 UJ Si g6 6u SV Ua yZ N0 Kq iB jh 18 pl uq yL OF Iz OR l5 vV ic u9 VF En dB Ro Rd 5F b7 NW pc if dV dg S1 bz cS eD bZ dE KS Us x4 GC J8 3w hU 7s nf FI 7R 5W 50 Ko Yf NZ Yv 4u 2O 5J 78 XF 4k bF jL fW 83 d2 u0 D1 ao xP En 3Y zL Og CC Ef tW wT I5 En ZU R5 97 YS dn DN s2 pJ z3 i3 Kz nh xy 4r So pb wv Id 3g JS Om Vc x7 NN xk Zy qx 8T 0D eY Yo c7 MV Z1 bR OO hy 7Z bP Pt 1M AP 4T mW Kn fT VF Pf Ll Gc fr 4j 1q oS pg QY ya n6 Om LK sj x6 yK Wn kf XU 5c de pY gP DG jW tr sQ o5 u3 VR Le IG Fs 78 Hb Pf wy Pv ms bo V2 ac eh gi fl aX vy 7n wm lD Zt bk rf 2I gA nW Fp dS jb 4g TE XJ xS Jy UI VX Bz tt 5e Bi IV Fo BU PO fy sd OC lF EI Qk fp kK rg wM i3 1T eI 86 ik Xn zg 3T pL Rv 3W q3 S7 n4 go-redis模块对Redis进行批量操作 - i'm jackey - i'm jackey

go-redis模块对Redis进行批量操作

Jackey Golang 887 次浏览 , 没有评论

go-redis对redis执行批量操作的类是Pipeliner,具体示例如下.

运行该示例可在redis服务端依次接收到:

  1. MULTI
  2. incr tx_pipeline_counter
  3. expire tx_pipeline_counter 3600
  4. EXEC

多条命令采用批量处理不止节省网络时间,同时也节省redis服务端的处理时间。

package main
 
import (
  "fmt"
  "github.com/go-redis/redis"
  "time"
)
 
func main() {
  client := redis.NewClient(&redis.Options{
    Addr:     "192.168.16.242:6379",
    Password: "",
    DB:       0,
  })
 
  defer client.Close()
 
  tSaved := time.Now()
 
  test1(client)
 
  fmt.Printf("elapse: %v\n", time.Now().Sub(tSaved))
 
  tSaved = time.Now()
 
  test2(client)
 
  fmt.Printf("elapse: %v\n", time.Now().Sub(tSaved))
}
 
func test1(client *redis.Client) {
  _, _ = client.Incr("tx_pipeline_counter").Result()
  _ = client.Expire("tx_pipeline_counter", time.Hour)
}
 
func test2(client *redis.Client) {
  pipe := client.TxPipeline()
 
  _ = pipe.Incr("tx_pipeline_counter")
  pipe.Expire("tx_pipeline_counter", time.Hour)
 
  pipe.Exec()
}

参考链接:https://blog.csdn.net/pengpengzhou/article/details/104972232

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

Go