springdata built redis use RedisTemplate

RedisTemplate common set of instructions -boundValueOps

boundValueOps () method using:

       We must first define a BoundValueOperations

BoundValueOperations boundValueOperations = redisTemplate.boundValueOps("bvo");  

 1.append(String value)

     At the end of the original value of the added value

boundValueOperations.append("a");  
boundValueOperations.append("b");  

2.get(long start, long end)

    Gets the specified range of position values

// Get all values   
System.out.println ( "Get all values:" + boundValueOperations.get ());  

 4.set(V value)

     To reset the value of key bindings

// reset the value   
boundValueOperations.set ( "F");   
System.out.println ( "reset the value:" + boundValueOperations.get ());  

5.set(V value, long timeout, TimeUnit unit)

    Reset value after a specified time

// reset after a specified time   
boundValueOperations.set ( "of wwww",. 5, TimeUnit.SECONDS);   
System.out.println ( "re-set after a specified time:" + boundValueOperations.get ());  

 6.set(V value, long offset)

    After adding the old value of specified length, taken behind the new value

Add a new value specified length // original value taken later   
boundValueOperations.set ( "nnnnnn",. 3);   
System.out.println ( "taken after a specified length of the original value after the add new values:" + boundValueOperations .get ());  

 7.setIfAbsent(V value)

    There is no value add

// add no value exists   
boundValueOperations.setIfAbsent ( "MMM");   
System.out.println ( "add no value exists:" + boundValueOperations.get ());  

 8.getAndSet(V value)

     Gets the original value and re-assigning new values

// Get the old value and new value coverage   
Object Object = boundValueOperations.getAndSet ( "yyy");   
of System.out.print ( "Get original value" Object +);   
System.out.println ( ", coverage new value: "+ boundValueOperations.get ());  

 9.size()

    Get the length of the binding value

System.out.println ( "length of the value the value:" + boundValueOperations.size ());  

 10.increment(double delta)和increment(long delta)

  Since growth in key, provided that the value of the type of binding is doule or long

// only from growth in digital type when it can   
boundValueOperations.increment (1);   
System.out.println ( "self-growth can only be in time for the digital type:" + boundValueOperations.get ());

Guess you like

Origin www.cnblogs.com/wufeng6/p/11921429.html