This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CloudEnvironment extends StandardServletEnvironment { | |
static Logger logger = LoggerFactory.getLogger(CloudEnvironment.class); | |
@Override | |
protected void customizePropertySources(MutablePropertySources propertySources) { | |
super.customizePropertySources(propertySources); | |
try { | |
//用来添加应用名到environment中 | |
propertySources.addLast(initResourcePropertySourceLocator("cloud-config-context.properties")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Bean | |
public CaffeineCacheManager writeCacheHalfMinute() { | |
CaffeineCacheManager caffeineCacheManager = new CaffeineCacheManager(CacheNames.Write.HALF_MINUTE); | |
caffeineCacheManager.setCaffeine(Caffeine.newBuilder() | |
.expireAfterWrite(30, TimeUnit.SECONDS) | |
.maximumSize(100)); | |
return caffeineCacheManager; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@GetMapping("create") | |
@Cacheable(value = CacheNames.Write.HALF_MINUTE, key = "#p0", cacheManager = "writeCacheHalfMinute") | |
public String test1(@RequestParam String user) throws InterruptedException { | |
log.error(user); | |
Thread.sleep(3000); | |
return "1111111111"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GOROOT=/usr/local/go #gosetup | |
GOPATH=/home/henry/go #gosetup | |
/usr/local/go/bin/go test -c -o /tmp/GoLand/___gobench_redis_test_go.test /code/go/test1/redis_test.go #gosetup | |
/tmp/GoLand/___gobench_redis_test_go.test -test.v -test.paniconexit0 -test.bench ^\QBenchmark100KKeys\E|\QBenchmark100KScan\E|\QBenchmark1MKeys\E|\QBenchmark1MScan\E$ -test.run ^$ | |
goos: linux | |
goarch: amd64 | |
cpu: Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz | |
Benchmark100KKeys | |
redis_test.go:95: Prepare 100K keys for keys command | |
100K keys size: dbsize: 100000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package xx.xx; | |
import com.fasterxml.jackson.core.JsonGenerator; | |
import com.fasterxml.jackson.core.JsonProcessingException; | |
import com.fasterxml.jackson.databind.*; | |
import com.fasterxml.jackson.databind.ser.DefaultSerializerProvider; | |
import com.fasterxml.jackson.databind.ser.SerializerFactory; | |
import java.io.IOException; | |
import java.util.List; |