@RunWith (springrunner.class)
@SpringBootTest public
class Redistest {
@Autowired
private Stringredistemplate stringredistemplate;
@Autowired
private redistemplate redistemplate;
/**
* Use Redis blur clear cache
/@Test public
void Testrediscache () {
String keys= "Test:";
Redistemplate.opsforvalue (). Set (Keys+1, "This is a test content!", 1000,timeunit.seconds);
String Content=redistemplate.opsforvalue (). Get (Keys+1). toString ();
System.out.println ("---------" gets the contents of the cache: "+content);
" Redistemplate.delete (Redistemplate.keys (keys+ "*"));
Object Msg=redistemplate.opsforvalue (). get (keys+1);
if (msg==null) {
msg= "no";
}
System.out.println ("---------" after the removal of the content is: "+msg);
}
Note: The prefix to be removed should be the nearest level eg: key=test:aa:bb:12345 then his prefix should be test:aa:bb:* so you can delete it.