一些容易忘记的spring boot知识要点.
注意,.yaml和.yml文件没任何区别.
配置
SpringBootApplication注解
@SpringBootApplication
// <=等价=>
@Configuration
@ComponentScan
@EnableAutoConfiguration
一些容易忘记的spring boot知识要点.
注意,.yaml和.yml文件没任何区别.
@SpringBootApplication
// <=等价=>
@Configuration
@ComponentScan
@EnableAutoConfiguration
Scala中很多使用if的地方都可以用match case来替换.常见的就是下面的这种写法:
val res = msg match {
case it if it.contains("H") => "Hello"
case _ => "Other"
}
//更常见的用法是去匹配参数的模式:
case class Player(name: String, score: Int)
def message(player: Player) = player match {
case Player(_, score) if score > 100000 =>
"Get a job, dude!"
case Player(name, _) =>
"Hey, $name, nice to see you again!"
}
def printMessage(player: Player) = println(message(player))
scala type class notes:
关于scala type class非常好的文章
some notes on scala, includes:
使用redis的hash优化内存使用
场景: 有3亿张图片放在对象存储(DELL ECS/AMAZON EC2)上面,现在需要保存图片的id->用户id的映射.最直接的思路是:
set "media:1155220" "user1"
set "media:1155221" "user2"
这样设计key之后3亿张图片需要21GB的内存,因为redis的string是线性增长的.