Skip to content

Instantly share code, notes, and snippets.

View TavenYin's full-sized avatar
😅

殷天文 TavenYin

😅
View GitHub Profile
@TavenYin
TavenYin / WeightRandom.java
Last active July 6, 2021 03:09
WeightRandom 权重随机算法
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
public class WeightRandom<T> {
ThreadLocal<Random> threadLocalRandom = ThreadLocal.withInitial(Random::new);
private final List<T> items = new ArrayList<>();
private double[] weights;
public WeightRandom(List<ItemWithWeight<T>> itemsWithWeight) {
[Unit]
Description=IRON consumer service
# 网络就绪后执行
After=network.target
[Service]
#
Type=simple
# 当服务进程 正常退出、异常退出、被杀死、超时的时候, 是否重新启动该服务,可选的值包括 always(总是重启)、on-success、on-failure、on-abnormal、on-abort、on-watchdog
Restart=always
git reset --hard 6c98c09e4ccf3e1808a0c0e40de637b63ae1ebbb // 回退到某一个提交
git push -f
@TavenYin
TavenYin / RedisLock.java
Created June 3, 2019 09:08
redis 分布式锁
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisCallback;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import redis.clients.jedis.Jedis;
import java.util.Collections;
@Service
public class RedisLock {