importassertfrom'assert';import{createClient}from'redis';constclient=awaitcreateClient();awaitclient.connect();constres1=awaitclient.set("bike:1","Deimos");console.log(res1);// OK
constres2=awaitclient.get("bike:1");console.log(res2);// Deimos
constres3=awaitclient.set("bike:1","bike",{'NX':true});console.log(res3);// null
console.log(awaitclient.get("bike:1"));// Deimos
constres4=awaitclient.set("bike:1","bike",{'XX':true});console.log(res4);// OK
constres5=awaitclient.mSet([["bike:1","Deimos"],["bike:2","Ares"],["bike:3","Vanth"]]);console.log(res5);// OK
constres6=awaitclient.mGet(["bike:1","bike:2","bike:3"]);console.log(res6);// ['Deimos', 'Ares', 'Vanth']
awaitclient.set("total_crashes",0);constres7=awaitclient.incr("total_crashes");console.log(res7);// 1
constres8=awaitclient.incrBy("total_crashes",10);console.log(res8);// 11
packageio.redis.examples;importredis.clients.jedis.UnifiedJedis;importredis.clients.jedis.params.SetParams;importjava.util.ArrayList;importjava.util.Arrays;importjava.util.List;publicclassStringExample{publicvoidrun(){try(UnifiedJedisjedis=newUnifiedJedis("redis://localhost:6379")){Stringres1=jedis.set("bike:1","Deimos");System.out.println(res1);// OK
Stringres2=jedis.get("bike:1");System.out.println(res2);// Deimos
Longres3=jedis.setnx("bike:1","bike");System.out.println(res3);// 0 (because key already exists)
System.out.println(jedis.get("bike:1"));// Deimos (value is unchanged)
Stringres4=jedis.set("bike:1","bike",SetParams.setParams().xx());// set the value to "bike" if it
// already
// exists
System.out.println(res4);// OK
Stringres5=jedis.mset("bike:1","Deimos","bike:2","Ares","bike:3","Vanth");System.out.println(res5);// OK
List<String>res6=jedis.mget("bike:1","bike:2","bike:3");System.out.println(res6);// [Deimos, Ares, Vanth]
jedis.set("total_crashes","0");Longres7=jedis.incr("total_crashes");System.out.println(res7);// 1
Longres8=jedis.incrBy("total_crashes",10);System.out.println(res8);// 11
}}}
importassertfrom'assert';import{createClient}from'redis';constclient=awaitcreateClient();awaitclient.connect();constres1=awaitclient.set("bike:1","Deimos");console.log(res1);// OK
constres2=awaitclient.get("bike:1");console.log(res2);// Deimos
constres3=awaitclient.set("bike:1","bike",{'NX':true});console.log(res3);// null
console.log(awaitclient.get("bike:1"));// Deimos
constres4=awaitclient.set("bike:1","bike",{'XX':true});console.log(res4);// OK
constres5=awaitclient.mSet([["bike:1","Deimos"],["bike:2","Ares"],["bike:3","Vanth"]]);console.log(res5);// OK
constres6=awaitclient.mGet(["bike:1","bike:2","bike:3"]);console.log(res6);// ['Deimos', 'Ares', 'Vanth']
awaitclient.set("total_crashes",0);constres7=awaitclient.incr("total_crashes");console.log(res7);// 1
constres8=awaitclient.incrBy("total_crashes",10);console.log(res8);// 11
packageio.redis.examples;importredis.clients.jedis.UnifiedJedis;importredis.clients.jedis.params.SetParams;importjava.util.ArrayList;importjava.util.Arrays;importjava.util.List;publicclassStringExample{publicvoidrun(){try(UnifiedJedisjedis=newUnifiedJedis("redis://localhost:6379")){Stringres1=jedis.set("bike:1","Deimos");System.out.println(res1);// OK
Stringres2=jedis.get("bike:1");System.out.println(res2);// Deimos
Longres3=jedis.setnx("bike:1","bike");System.out.println(res3);// 0 (because key already exists)
System.out.println(jedis.get("bike:1"));// Deimos (value is unchanged)
Stringres4=jedis.set("bike:1","bike",SetParams.setParams().xx());// set the value to "bike" if it
// already
// exists
System.out.println(res4);// OK
Stringres5=jedis.mset("bike:1","Deimos","bike:2","Ares","bike:3","Vanth");System.out.println(res5);// OK
List<String>res6=jedis.mget("bike:1","bike:2","bike:3");System.out.println(res6);// [Deimos, Ares, Vanth]
jedis.set("total_crashes","0");Longres7=jedis.incr("total_crashes");System.out.println(res7);// 1
Longres8=jedis.incrBy("total_crashes",10);System.out.println(res8);// 11
}}}
importassertfrom'assert';import{createClient}from'redis';constclient=awaitcreateClient();awaitclient.connect();constres1=awaitclient.set("bike:1","Deimos");console.log(res1);// OK
constres2=awaitclient.get("bike:1");console.log(res2);// Deimos
constres3=awaitclient.set("bike:1","bike",{'NX':true});console.log(res3);// null
console.log(awaitclient.get("bike:1"));// Deimos
constres4=awaitclient.set("bike:1","bike",{'XX':true});console.log(res4);// OK
constres5=awaitclient.mSet([["bike:1","Deimos"],["bike:2","Ares"],["bike:3","Vanth"]]);console.log(res5);// OK
constres6=awaitclient.mGet(["bike:1","bike:2","bike:3"]);console.log(res6);// ['Deimos', 'Ares', 'Vanth']
awaitclient.set("total_crashes",0);constres7=awaitclient.incr("total_crashes");console.log(res7);// 1
constres8=awaitclient.incrBy("total_crashes",10);console.log(res8);// 11
packageio.redis.examples;importredis.clients.jedis.UnifiedJedis;importredis.clients.jedis.params.SetParams;importjava.util.ArrayList;importjava.util.Arrays;importjava.util.List;publicclassStringExample{publicvoidrun(){try(UnifiedJedisjedis=newUnifiedJedis("redis://localhost:6379")){Stringres1=jedis.set("bike:1","Deimos");System.out.println(res1);// OK
Stringres2=jedis.get("bike:1");System.out.println(res2);// Deimos
Longres3=jedis.setnx("bike:1","bike");System.out.println(res3);// 0 (because key already exists)
System.out.println(jedis.get("bike:1"));// Deimos (value is unchanged)
Stringres4=jedis.set("bike:1","bike",SetParams.setParams().xx());// set the value to "bike" if it
// already
// exists
System.out.println(res4);// OK
Stringres5=jedis.mset("bike:1","Deimos","bike:2","Ares","bike:3","Vanth");System.out.println(res5);// OK
List<String>res6=jedis.mget("bike:1","bike:2","bike:3");System.out.println(res6);// [Deimos, Ares, Vanth]
jedis.set("total_crashes","0");Longres7=jedis.incr("total_crashes");System.out.println(res7);// 1
Longres8=jedis.incrBy("total_crashes",10);System.out.println(res8);// 11
}}}
importassertfrom'assert';import{createClient}from'redis';constclient=awaitcreateClient();awaitclient.connect();constres1=awaitclient.set("bike:1","Deimos");console.log(res1);// OK
constres2=awaitclient.get("bike:1");console.log(res2);// Deimos
constres3=awaitclient.set("bike:1","bike",{'NX':true});console.log(res3);// null
console.log(awaitclient.get("bike:1"));// Deimos
constres4=awaitclient.set("bike:1","bike",{'XX':true});console.log(res4);// OK
constres5=awaitclient.mSet([["bike:1","Deimos"],["bike:2","Ares"],["bike:3","Vanth"]]);console.log(res5);// OK
constres6=awaitclient.mGet(["bike:1","bike:2","bike:3"]);console.log(res6);// ['Deimos', 'Ares', 'Vanth']
awaitclient.set("total_crashes",0);constres7=awaitclient.incr("total_crashes");console.log(res7);// 1
constres8=awaitclient.incrBy("total_crashes",10);console.log(res8);// 11
packageio.redis.examples;importredis.clients.jedis.UnifiedJedis;importredis.clients.jedis.params.SetParams;importjava.util.ArrayList;importjava.util.Arrays;importjava.util.List;publicclassStringExample{publicvoidrun(){try(UnifiedJedisjedis=newUnifiedJedis("redis://localhost:6379")){Stringres1=jedis.set("bike:1","Deimos");System.out.println(res1);// OK
Stringres2=jedis.get("bike:1");System.out.println(res2);// Deimos
Longres3=jedis.setnx("bike:1","bike");System.out.println(res3);// 0 (because key already exists)
System.out.println(jedis.get("bike:1"));// Deimos (value is unchanged)
Stringres4=jedis.set("bike:1","bike",SetParams.setParams().xx());// set the value to "bike" if it
// already
// exists
System.out.println(res4);// OK
Stringres5=jedis.mset("bike:1","Deimos","bike:2","Ares","bike:3","Vanth");System.out.println(res5);// OK
List<String>res6=jedis.mget("bike:1","bike:2","bike:3");System.out.println(res6);// [Deimos, Ares, Vanth]
jedis.set("total_crashes","0");Longres7=jedis.incr("total_crashes");System.out.println(res7);// 1
Longres8=jedis.incrBy("total_crashes",10);System.out.println(res8);// 11
}}}