Scripting: expire keys in scripts only at first access.
Scripting: expire keys in scripts only at first access.

Keys expiring in the middle of the execution of Lua scripts are to
create inconsistencies in masters and / or AOF files. See the following
example:

    if redis.call("exists",KEYS[1]) == 1
    then
        redis.call("incr","mycounter")
    end

    if redis.call("exists",KEYS[1]) == 1
    then
        return redis.call("incr","mycounter")
    end

The script executes two times the same *if key exists then incrementcounter*
logic. However the two executions will work differently in the master and
the slaves, provided some unlucky timing happens.

In the master the first time the key may still exist, while the second time
the key may no longer exist. This will result in the key incremented just one
time. However as a side effect the master will generate a synthetic
`DEL` command in the replication channel in order to force the slaves to
expire the key (given that key expiration is master-driven).

When the same script will run in the slave, the key will no longer be
there, so the script will not increment the key.

The key idea used to implement the expire-at-first-lookup semantics was
provided by Marc Gravell.

soloestoy/redis,pmem/redis,saisai/redis,wprice/redis,nnog/redis,atreeyang/redis,ton31337/redis,4396/redis,LongXQ/redis,programmecat/redis,josiahcarlson/redis,pkdevbox/redis,xujunhai1991/redis,ouyangkongtong/redis,qiyang0221/redis,duanx/redis,pkdevbox/redis,ksarch-saas/redis,brg-liuwei/redis,linfangrong/redis,Aaron1992/redis,pkdevbox/redis,xuzhezhaozhao/redis_reading,soloestoy/redis,YongMan/redis,pcarrier/redis,huyuezheng/redis,190235047/redis,PKRoma/redis,mcanthony/redis,cnbin/redis,davidradunz/redis,ouyangkongtong/redis,badboy/redis,RepmujNetsik/redis,a-pavlov/redis,ctripcorp/redis,mgk/redis,wujf/redis,flashbuckets/redis,mcanthony/redis,z-fork/redis,charsyam/redis,brg-liuwei/redis,MOON-CLJ/redis,ytjiang/redis,simplestbest/redis,abhiklodh/redis,tellapart/redis,HunanTV/redis,charsyam/redis,clamoriniere1A/redis,sunheehnus/redis,seppo0010/rlite-server,ouyangkongtong/redis,gilala/bjredis,itamarhaber/redis,harrisonfeng/redis,ErikDubbelboer/redis,mengzhejin/RedisStudy,SummonY/redis,AALEKH/redis,zhiliaoniu/redis,netroby/redis,yossigo/redis,Sciumo/redis,maodeyi/redis_lua,charsyam/redis,kmiku7/redis,badboy/redis,gilala/hbjredis,shining-yang/redis,programmecat/redis,riyan8250/redis,OmarQunsul/graph-redis,programmecat/redis,valdsJohn/redis,neomantra/redis,wangyikai/redis,slfs007/mk-redis,HeartSaVioR/redis,MSOpenTech/redis,maodeyi/redis_lua,janekmi/redis,clamoriniere1A/redis,zczhuohuo/redis,wprice/redis,seppo0010/redis,MasahikoSawada/redis,guker/redis,csuhawk/redis,4396/redis,Markgorden/redis,splitice/redis,190235047/redis,zczhuohuo/redis,MSOpenTech/redis,duanx/redis,itamarhaber/redis,pmem/redis,taoguan/redis,flashbuckets/redis,ErikDubbelboer/redis,AALEKH/redis,HunanTV/redis,nuxeh/redis,ofirluzon/redis,blackmady/redis,YongMan/redis,HeartSaVioR/redis,rogerlz/redis,holstvoogd/redis,kensou97/redis,JoeWoo/redis,izhoujie/redis,4396/redis,idning/redis,fengshao0907/redis,darksideofthemoo/redis-histogram,idning/redis,huyuezheng/redis,soloestoy/redis,ofirluzon/redis,riyan8250/redis,Aliceljm1/redis,ctripcorp/redis,takeshineshiro/redis,abhiklodh/redis,a-pavlov/redis,aim-for-better/redis,HeartSaVioR/redis,antirez/redis,mumingv/redis,ketor/redis,seandsky/redis,StevenTsai/redis,csuhawk/redis,a-pavlov/redis,xujunhai1991/redis,netroby/redis,jasonkying/redis,shreesundara/redis,ramonsnir/redis,YuanZhewei/redis,Sciumo/redis,StevenTsai/redis,pkdevbox/redis,healerkx/redis,mengzhejin/RedisStudy,brg-liuwei/redis,elkingtonmcb/redis,nnog/redis,z-fork/redis,izhoujie/redis,weizijun/redis,Sciumo/redis,idning/redis,dreamquster/redis,jbochi/redis,yossigo/redis,saisai/redis,shreesundara/redis,mumingv/redis,francischan714/redis,mengyou0304/redis,devaos/redis,SummonY/redis,cloudrain21/redis,holstvoogd/redis,YuraLukashik/redis,hgl888/redis,mverrilli/redis,oranagra/redis,allengaller/redis,wangyikai/redis,holstvoogd/redis,tjschuck/redis,yybirdcf/learn-redis,saisai/redis,louisliangjun/redis,narma/redis,zhiliaoniu/redis,OmarQunsul/graph-redis,Markgorden/redis,jasonkying/redis,josiahcarlson/redis,huyuezheng/redis,narma/redis,PradheepShrinivasan/redis,nuxeh/redis,himoca/redis,rouzier/redis,ofirluzon/redis,slfs007/mk-redis,wbailey5/redis,nnog/redis,supasate/redis,wujf/redis,iandyh/redis,ncopa/redis,simplestbest/redis,mingyaaaa/redis,wbailey5/redis,saisai/redis,PKRoma/redis,netroby/redis,modulexcite/redis,tellapart/redis,mumingv/redis,wenxueliu/redis_comment,hedisdb/hedis,ytjiang/redis,jackyan/redis,jingjidejuren/redis,gilala/hbjredis,MSOpenTech/redis,AALEKH/redis,seppo0010/redis,citusdata/redis,splitice/redis,guker/redis,j0hnma/hszredis,colstrom/redis,izhoujie/redis,janekmi/redis,MasahikoSawada/redis,harrisonfeng/redis,rouzier/redis,MasahikoSawada/redis,wenxueliu/redis_comment,xujunhai1991/redis,CodeJuan/redis,louisliangjun/redis,francischan714/redis,ksarch-saas/redis,gaoxianglong/redis,yuhc/redis-benchmark-enhanced,flashbuckets/redis,Soledad89/redis,ncopa/redis,devaos/redis,tanghaodong25/redis,ttuna/msot-redis,healerkx/redis,modulexcite/redis,splitice/redis,roth1002/redis,harrisonfeng/redis,soveran/redis,yuhc/redis-benchmark-enhanced,himoca/redis,arijitvt/redis,wprice/redis,MOON-CLJ/redis,mingyaaaa/redis,GrimDerp/redis,programmecat/redis,gilala/redis,twskipper/redis,tanghaodong25/redis,gaoxianglong/redis,devaos/redis,antirez/redis,yybirdcf/learn-redis,SyntaxStacks/redis,yossigo/redis,MasahikoSawada/redis,alenslan/redis,july2993/redis,xuzhezhaozhao/redis_reading,hgl888/redis,gilala/hredis,jxwr/redis,qiyang0221/redis,mcanthony/redis,GitHubMota/redis,rogerlz/redis,SyntaxStacks/redis,francischan714/redis,wprice/redis,mattsta/redis,jbochi/parallel_redis,soveran/redis,jbochi/redis,itugs/redis,PradheepShrinivasan/redis,hedisdb/hedis,ton31337/redis,josiahcarlson/redis,citusdata/redis,SummonY/redis,wenxueliu/redis_comment,itugs/redis,PradheepShrinivasan/redis,janekmi/redis,GitHubMota/redis,j0hnma/hszredis,honestme/redis,AALEKH/redis,PKRoma/redis,soveran/redis,seppo0010/redis,rogerlz/redis,Wangyao14cyy/redis,gilala/redis,pedigree/redis,dreamquster/redis,ipmobiletech/redis,ton31337/redis,OmarQunsul/graph-redis,rouzier/redis,charsyam/redis,mengyou0304/redis,mengyou0304/redis,zhiliaoniu/redis,NBSW/redis,july2993/redis,mengzhejin/RedisStudy,modulexcite/redis,weizijun/redis,pcarrier/redis,blackmady/redis,jingjidejuren/redis,colstrom/redis,jbochi/redis,Wangyao14cyy/redis,Aaron1992/redis,Hailei/redis,takeshineshiro/redis,dayuoba/redis,gilala/redis,aim-for-better/redis,pmem/redis,zhcy/redis,darksideofthemoo/redis-histogram,qiyang0221/redis,sunheehnus/redis,itamarhaber/redis,JoeWoo/redis,qiyang0221/redis,elkingtonmcb/redis,ituncle/redis,himoca/redis,allengaller/redis,soveran/redis,SyntaxStacks/redis,PKRoma/redis,YuraLukashik/redis,cloudrain21/redis,xuguruogu/redis,timothyohare/3rdPartySrc-redis,atreeyang/redis,RepmujNetsik/redis,YuanZhewei/redis,PKRoma/redis,xlzhan/redis,Wangyao14cyy/redis,sunheehnus/redis,roth1002/redis,ytjiang/redis,cusspvz/redis,cusspvz/redis,z-fork/redis,davidradunz/redis,valdsJohn/redis,pedigree/redis,xlzhan/redis,ofirluzon/redis,blackmady/redis,cusspvz/redis,Hailei/redis,hgl888/redis,ttuna/msot-redis,pmem/redis,MSOpenTech/redis,shining-yang/redis,YuraLukashik/redis,shining-yang/redis,zhcy/redis,ErikDubbelboer/redis,roth1002/redis,weizijun/redis,gilala/bjredis,soloestoy/redis,antirez/redis,badboy/redis,valdsJohn/redis,kensou97/redis,jackyan/redis,blackmady/redis,dreamquster/redis,cnbin/redis,CodeJuan/redis,hawkchch/redis,xuguruogu/redis,maodeyi/redis_lua,ketor/redis,neomantra/redis,ksarch-saas/redis,wujf/redis,wangyikai/redis,timothyohare/3rdPartySrc-redis,wbailey5/redis,gilala/bjredis,csuhawk/redis,ituncle/redis,h0x91b/redis,flashbuckets/redis,YongMan/redis,colstrom/redis,nuxeh/redis,july2993/redis,ncopa/redis,timothyohare/3rdPartySrc-redis,wangyikai/redis,cnbin/redis,aim-for-better/redis,idning/redis,4396/redis,ouyangkongtong/redis,citusdata/redis,pedigree/redis,ttuna/msot-redis,Hailei/redis,hornen/redis,valdsJohn/redis,wbailey5/redis,aim-for-better/redis,gilala/hbjredis,darksideofthemoo/redis-histogram,thomasdarimont/redis,netroby/redis,seandsky/redis,h0x91b/redis,ofirluzon/redis,twskipper/redis,timothyohare/3rdPartySrc-redis,shreesundara/redis,h0x91b/redis,mingyaaaa/redis,supasate/redis,ton31337/redis,splitice/redis,fengshao0907/redis,clamoriniere1A/redis,thomasdarimont/redis,dayuoba/redis,ctripcorp/redis,takeshineshiro/redis,xuzhezhaozhao/redis_reading,zczhuohuo/redis,Markgorden/redis,jxwr/redis,jingjidejuren/redis,ituncle/redis,hedisdb/hedis,kensou97/redis,linfangrong/redis,universsky/redis,taoguan/redis,Aaron1992/redis,itamarhaber/redis,spinlock/redis,mverrilli/redis,Sciumo/redis,tjschuck/redis,gilala/bjredis,thomasdarimont/redis,mverrilli/redis,MOON-CLJ/redis,itugs/redis,spinlock/redis,yuhc/redis-benchmark-enhanced,ncopa/redis,elkingtonmcb/redis,mengzhejin/RedisStudy,xuguruogu/redis,oranagra/redis,fengshao0907/redis,universsky/redis,mgk/redis,brg-liuwei/redis,ramonsnir/redis,shining-yang/redis,duanx/redis,zguangyu/redis,takeshineshiro/redis,JoeWoo/redis,YuanZhewei/redis,j0hnma/szredis,universsky/redis,hgl888/redis,honestme/redis,simplestbest/redis,SummonY/redis,zguangyu/redis,tjschuck/redis,iandyh/redis,HunanTV/redis,mingyaaaa/redis,tjschuck/redis,clamoriniere1A/redis,allengaller/redis,AplayER/redis,ctripcorp/redis,CodeJuan/redis,iandyh/redis,seandsky/redis,GrimDerp/redis,GitHubMota/redis,StevenTsai/redis,gilala/hredis,cloudrain21/redis,ksarch-saas/redis,pcarrier/redis,yossigo/redis,louisliangjun/redis,StevenTsai/redis,mattsta/redis,xlzhan/redis,atreeyang/redis,190235047/redis,guker/redis,AplayER/redis,yossigo/redis,Aliceljm1/redis,slfs007/mk-redis,cusspvz/redis,gaoxianglong/redis,charsyam/redis,darksideofthemoo/redis-histogram,kaushik94/redis,kaushik94/redis,hawkchch/redis,allengaller/redis,Aliceljm1/redis,tanghaodong25/redis,ttuna/msot-redis,ramonsnir/redis,PradheepShrinivasan/redis,xlzhan/redis,a-pavlov/redis,davidradunz/redis,citusdata/redis,rogerchina/redis,ttuna/msot-redis,hornen/redis,jxwr/redis,cnbin/redis,duanx/redis,josiahcarlson/redis,harrisonfeng/redis,rouzier/redis,spearhead-ea/redis,MSOpenTech/redis,jasonkying/redis,YongMan/redis,riyan8250/redis,seppo0010/rlite-server,Soledad89/redis,janekmi/redis,zczhuohuo/redis,wujf/redis,pedigree/redis,mgk/redis,ipmobiletech/redis,healerkx/redis,mcanthony/redis,vincent-vivian-liu/redis,alenslan/redis,alenslan/redis,ipmobiletech/redis,rogerchina/redis,HeartSaVioR/redis,mengyou0304/redis,tellapart/redis,izhoujie/redis,neomantra/redis,nnog/redis,j0hnma/hszredis,kaushik94/redis,spearhead-ea/redis,jbochi/parallel_redis,z-fork/redis,louisliangjun/redis,GrimDerp/redis,ketor/redis,CodeJuan/redis,itugs/redis,atreeyang/redis,iandyh/redis,huyuezheng/redis,seppo0010/redis,j0hnma/hszredis,colstrom/redis,francischan714/redis,kmiku7/redis,NBSW/redis,kmiku7/redis,RepmujNetsik/redis,dayuoba/redis,devaos/redis,guker/redis,yybirdcf/learn-redis,zhcy/redis,seppo0010/rlite-server,zhcy/redis,hornen/redis,weizijun/redis,gilala/hredis,xuguruogu/redis,simplestbest/redis,NBSW/redis,mgk/redis,twskipper/redis,oranagra/redis,rogerchina/redis,neomantra/redis,jackyan/redis,190235047/redis,vincent-vivian-liu/redis,davidradunz/redis,GrimDerp/redis,HunanTV/redis,Wangyao14cyy/redis,supasate/redis,AplayER/redis,rogerchina/redis,xuzhezhaozhao/redis_reading,cloudrain21/redis,honestme/redis,csuhawk/redis,ituncle/redis,july2993/redis,Soledad89/redis,badboy/redis,seandsky/redis,Aaron1992/redis,yuhc/redis-benchmark-enhanced,jbochi/parallel_redis,elkingtonmcb/redis,linfangrong/redis,vincent-vivian-liu/redis,yybirdcf/learn-redis,riyan8250/redis,dayuoba/redis,seppo0010/rlite-server,LongXQ/redis,fengshao0907/redis,AplayER/redis,modulexcite/redis,tanghaodong25/redis,abhiklodh/redis,kmiku7/redis,dreamquster/redis,NBSW/redis,vincent-vivian-liu/redis,neomantra/redis,zguangyu/redis,linfangrong/redis,jasonkying/redis,alenslan/redis,hedisdb/hedis,Soledad89/redis,oranagra/redis,spinlock/redis,twskipper/redis,ytjiang/redis,taoguan/redis,ErikDubbelboer/redis,gaoxianglong/redis,LongXQ/redis,spinlock/redis,narma/redis,thomasdarimont/redis,SyntaxStacks/redis,arijitvt/redis,JoeWoo/redis,LongXQ/redis,h0x91b/redis,j0hnma/szredis,supasate/redis,mverrilli/redis,hawkchch/redis,universsky/redis,oranagra/redis,mattsta/redis,YuanZhewei/redis,tellapart/redis,gilala/hredis,pcarrier/redis,rogerlz/redis,taoguan/redis,xujunhai1991/redis,RepmujNetsik/redis,kensou97/redis,jackyan/redis,arijitvt/redis,hawkchch/redis,OmarQunsul/graph-redis,shreesundara/redis,zhiliaoniu/redis,hornen/redis,holstvoogd/redis,kaushik94/redis,GitHubMota/redis,healerkx/redis,gilala/redis,antirez/redis,j0hnma/szredis,ipmobiletech/redis,j0hnma/szredis,zguangyu/redis,soloestoy/redis,arijitvt/redis,YuraLukashik/redis,Aliceljm1/redis,abhiklodh/redis,mumingv/redis,gilala/hbjredis,Markgorden/redis,spearhead-ea/redis,wenxueliu/redis_comment,sunheehnus/redis,roth1002/redis,Hailei/redis,honestme/redis,nuxeh/redis,jingjidejuren/redis