Spring redistemplate Operation-zset operation (6)

Source: Internet
Author: User

@Autowired @Resource (name= "Redistemplate")    PrivateRedistemplate<string, string>RT;  Public voidflushdb () {Rt.execute (NewRediscallback<object>() {             PublicString Doinredis (redisconnection connection)throwsDataAccessException {connection.flushdb (); return"OK";    }        }); }         Public voidset () {flushdb (); Zsetoperations<string, string> vo =Rt.opsforzset (); Vo.add ("Book", "a", 1d); Vo.add ("Book", "B", 2d); Set<TypedTuple<String>> tuples =NewHashset<>(); Typedtuple<String> TUPLE0 =NewDefaulttypedtuple<string> ("C", 3d);        Tuples.add (TUPLE0); Typedtuple<String> Tuple1 =NewDefaulttypedtuple<string> ("D", 4d);        Tuples.add (TUPLE1); Typedtuple<String> Tuple2 =NewDefaulttypedtuple<string> ("E", 5d);                Tuples.add (Tuple2); Vo.add ("Book", tuples); Vo.incrementscore ("Book", "E", 1d); Vo.add ("Book", "F", 7); Vo.add ("Book", "G", 8); Vo.add ("Book", "H", 9); //vo.remove ("book", "G", "H");Vo.removerange ("book", 7, 8); Vo.removerangebyscore ("Book", 8, 9); }         Public voidget () {zsetoperations<string, string> vo =Rt.opsforzset (); Out (Vo.score ("Book", "E")); Out (Vo.rank ("Book", "E")); Out (Vo.reverserank ("Book", "E")); Out (Vo.zcard ("Book")); Out (Vo.range ("Book", 0,-1));//Out (The Vo.rangewithscores ("book", 0,-1));Out (The Vo.count ("book", 2, 4));//containing theVo.rangebylex ("book", Range.range (). LTE ("F"). GTE ("B"))); Out (Vo.rangebylex ("Book", Range.range (), Limit.limit (). Count (2). Offset (0))); Out (Vo.rangebylex ("Book", Range.range (), Limit.limit (). Count (2). Offset (2))); Out (Vo.rangebyscore ("Book", 2, 4)); Out (Vo.rangebyscore ("Book", 2, 4, 0, 2));//Out (The Vo.rangebyscorewithscores ("book", 2, 4));//Out (The Vo.rangebyscorewithscores ("book", 2, 4, 0, 2));Out (Vo.reverserange ("Book", 0,-1)); Out (Vo.reverserangebyscore ("Book", 2, 4)); Out (Vo.reverserangebyscore ("Book", 2, 4, 0, 2)); }         Public voidout (String str) {System.out.println (str); }     Public voidout (Collection list) {System.out.println (list); }     Public voidOutLongnum)    {System.out.println (num); }     Public voidOutBooleannum)    {System.out.println (num); }     Public voidout (DataType num) {System.out.println (num); }     Public voidout (Object str) {System.out.println (str); }     Public voidOut (set<typedtuple<string>>set) {         for(typedtuple<string>T:set) {System.out.println (T.getvalue ()+"---"+T.getscore ()); }    }

Spring redistemplate Operation-zset operation (6)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.