最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Redis Caffeine多級緩存框架的實現(xiàn)

 更新時間:2026年04月01日 10:31:13   作者:哈哈哈笑什么  
本文主要介紹了Redis Caffeine多級緩存框架的實現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

一、框架核心概述(是什么)

這是一套 本地緩存(Caffeine)+ 分布式緩存(Redis)的多級緩存框架,基于 Spring 生態(tài)實現(xiàn),核心目標(biāo)是兼顧緩存訪問性能與分布式環(huán)境下的數(shù)據(jù)一致性。

核心特性

  • 多級緩存架構(gòu):一級緩存(本地 Caffeine)提升響應(yīng)速度,二級緩存(Redis)保證分布式一致性
  • 靈活配置:支持過期時間、過期模式、NULL 值緩存、本地緩存容量限制等
  • 動態(tài) Key 生成:基于 SpEL 表達(dá)式實現(xiàn)緩存 Key 動態(tài)拼接
  • 并發(fā)安全:內(nèi)置分布式鎖(Redisson),解決緩存穿透/擊穿/雪崩問題
  • 完整 API:支持緩存增刪改查、原子操作、批量處理等

技術(shù)棧依賴

  • 核心框架:Spring Boot、Spring Context
  • 緩存組件:Caffeine(本地緩存)、Redis(分布式緩存)
  • 分布式鎖:Redisson
  • 序列化:Jackson
  • 表達(dá)式解析:Spring EL

二、框架核心價值(為什么用)

1. 解決的核心問題

問題場景框架解決方案
緩存穿透(查詢不存在的數(shù)據(jù))支持 NULL 值緩存 + 分布式鎖防重復(fù)查詢
緩存擊穿(熱點 Key 過期)分布式鎖 + 緩存自動續(xù)期
緩存雪崩(大量 Key 同時過期)過期時間隨機(jī)偏移 + 多級緩存降級
分布式緩存一致性Redis 集中存儲 + 緩存更新同步
本地緩存性能瓶頸Caffeine 本地緩存(O(1) 訪問速度)

2. 相比單一緩存的優(yōu)勢

  • 比純 Redis 緩存:減少網(wǎng)絡(luò) IO 開銷,本地緩存響應(yīng)時間提升 10-100 倍
  • 比純本地緩存:支持分布式部署,避免節(jié)點間數(shù)據(jù)不一致
  • 比 Spring Cache 原生:支持更靈活的配置(過期模式、容量限制)和更完善的并發(fā)控制

三、快速上手(怎么做)

1. 依賴配置(Maven)

<!-- Spring Boot 基礎(chǔ)依賴 -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!-- Caffeine 本地緩存 -->
<dependency>
    <groupId>com.github.ben-manes.caffeine</groupId>
    <artifactId>caffeine</artifactId>
    <version>3.1.8</version>
</dependency>
<!-- Redisson 分布式鎖 -->
<dependency>
    <groupId>org.redisson</groupId>
    <artifactId>redisson-spring-boot-starter</artifactId>
    <version>3.25.0</version>
</dependency>
<!-- Jackson 序列化 -->
<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
</dependency>

2. 配置文件(application.yml)

spring:
  application:
    name: demo-app # 用于 Redis Key 前綴
  redis:
    host: 127.0.0.1
    port: 6379
    password: 123456
    timeout: 3000ms
    lettuce:
      pool:
        max-active: 8
        max-idle: 8
        min-idle: 2

3. 基礎(chǔ)使用示例

3.1 編程式使用(直接操作緩存 API)

import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;
@Service
public class UserService {
    // 注入緩存管理器
    @Resource
    private CacheManager cacheManager;
    // 緩存配置(可通過 @ConfigurationProperties 注入)
    private final MultiCacheConfig userCacheConfig = new MultiCacheConfig(
        30, TimeUnit.MINUTES, 20, true, true // ttl=30分鐘,允許緩存NULL,啟用本地緩存
    );
    /**
     * 查詢用戶:緩存命中返回,未命中查庫并緩存
     */
    public User getUserById(Long userId) {
        // 1. 獲取緩存實例(緩存名稱:userCache)
        Cache cache = cacheManager.getCache("userCache", userCacheConfig);
        // 2. 生成緩存Key(支持SpEL表達(dá)式,這里直接拼接)
        String cacheKey = "user:" + userId;
        // 3. 緩存查詢(未命中時執(zhí)行Supplier查庫)
        return (User) cache.get(cacheKey, User.class, () -> {
            // 數(shù)據(jù)庫查詢邏輯(僅緩存未命中時執(zhí)行)
            return userDao.selectById(userId);
        });
    }
    /**
     * 更新用戶:同步更新數(shù)據(jù)庫和緩存
     */
    public void updateUser(User user) {
        Cache cache = cacheManager.getCache("userCache", userCacheConfig);
        String cacheKey = "user:" + user.getId();
        // 1. 更新數(shù)據(jù)庫
        userDao.updateById(user);
        // 2. 更新緩存(覆蓋舊值)
        cache.put(cacheKey, user);
    }
    /**
     * 刪除用戶:同步刪除數(shù)據(jù)庫和緩存
     */
    public void deleteUser(Long userId) {
        Cache cache = cacheManager.getCache("userCache", userCacheConfig);
        String cacheKey = "user:" + userId;
        // 1. 刪除數(shù)據(jù)庫記錄
        userDao.deleteById(userId);
        // 2. 刪除緩存(避免臟數(shù)據(jù))
        cache.evict(cacheKey);
    }
}

3.2 注解式使用(基于 AOP 切面)

import java.lang.annotation.*;
// 1. 自定義緩存注解(可擴(kuò)展)
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface MyCacheable {
    String cacheName(); // 緩存名稱
    String key() default ""; // SpEL表達(dá)式Key
    MultiCacheConfig config() default @MultiCacheConfig(); // 緩存配置
}
// 2. 注解切面實現(xiàn)(基于 AbstractCacheAspectSupport)
@Aspect
@Component
public class CacheAspect extends AbstractCacheAspectSupport {
    @Resource
    private CacheManager cacheManager;
    @Around("@annotation(myCacheable)")
    public Object cacheAroundAdvice(ProceedingJoinPoint joinPoint, MyCacheable myCacheable) throws Throwable {
        // 獲取方法信息
        Method method = getSpecificMethod(joinPoint);
        Object[] args = joinPoint.getArgs();
        Object target = joinPoint.getTarget();
        // 解析緩存Key(支持SpEL表達(dá)式)
        String cacheKey = (String) generateKey(myCacheable.key(), method, args, target);
        // 獲取緩存實例
        Cache cache = cacheManager.getCache(myCacheable.cacheName(), myCacheable.config());
        // 緩存查詢:命中返回,未命中執(zhí)行目標(biāo)方法并緩存
        return cache.get(cacheKey, method.getReturnType(), () -> {
            try {
                return joinPoint.proceed();
            } catch (Throwable e) {
                throw new RuntimeException("緩存加載失敗", e);
            }
        });
    }
}
// 3. 業(yè)務(wù)層使用注解
@Service
public class ProductService {
    @MyCacheable(
        cacheName = "productCache",
        key = "#root.methodName + ':' + #p0", // SpEL:方法名+第一個參數(shù)
        config = @MultiCacheConfig(ttl = 60, timeUnit = TimeUnit.MINUTES, cacheNullValues = true)
    )
    public Product getProductById(Long productId) {
        // 數(shù)據(jù)庫查詢邏輯(緩存未命中時執(zhí)行)
        return productDao.selectById(productId);
    }
}

四、核心組件詳解

1. 緩存核心接口(Cache)

定義緩存操作標(biāo)準(zhǔn) API,所有緩存實現(xiàn)的頂層接口:

public interface Cache {
    // 獲取緩存(未命中返回null)
    <T> T get(String key, Class<T> resultType);
    // 獲取緩存(未命中執(zhí)行valueLoader加載并緩存)
    <T> T get(String key, Class<T> resultType, Supplier<Object> valueLoader);
    // 添加/覆蓋緩存
    void put(String key, Object value);
    // 原子操作:不存在時才添加
    boolean putIfAbsent(String key, Object value);
    // 單個刪除
    void evict(String key);
    // 批量刪除
    void multiEvict(Collection<String> keys);
    // 清空緩存
    void clear();
}

2. 多級緩存實現(xiàn)(MultiLevelCache)

整合 Caffeine 本地緩存和 Redis 分布式緩存:

public class MultiLevelCache implements Cache {
    private final String cacheName;
    private final CaffeineCache localCache; // 一級緩存(本地)
    private final RedisCache remoteCache; // 二級緩存(Redis)
    private final boolean cacheNullValues; // 是否緩存NULL值
    private final boolean enableLocalCache; // 是否啟用本地緩存
    // 核心邏輯:查詢緩存時先查本地,再查Redis,最后查庫
    @Override
    public <T> T get(String key, Class<T> resultType, Supplier<Object> valueLoader) {
        // 1. 查本地緩存
        if (enableLocalCache) {
            T localValue = localCache.get(key, resultType);
            if (resultType.isInstance(localValue) && !NullValue.isNullValue(localValue)) {
                return localValue;
            }
        }
        // 2. 查Redis緩存
        T remoteValue = remoteCache.get(key, resultType);
        if (resultType.isInstance(remoteValue) && !NullValue.isNullValue(remoteValue)) {
            // 同步到本地緩存
            if (enableLocalCache) {
                localCache.put(key, remoteValue);
            }
            return remoteValue;
        }
        // 3. 緩存未命中,執(zhí)行加載邏輯(查庫)
        Object value = valueLoader.get();
        // 4. 緩存結(jié)果(支持NULL值)
        put(key, value);
        return resultType.cast(fromStoreValue(value));
    }
    // 其他方法:put/evict/clear 均同步操作本地和Redis緩存
}

3. 緩存管理器(CacheManager)

負(fù)責(zé)緩存實例的創(chuàng)建和管理,采用懶加載模式:

public interface CacheManager {
    // 獲取緩存(不存在返回null)
    Cache getCache(String name);
    // 獲取緩存(不存在則創(chuàng)建)
    Cache getCache(String name, MultiCacheConfig config);
}
// 抽象實現(xiàn)類
public abstract class AbstractCacheManager implements CacheManager {
    // 緩存容器(ConcurrentHashMap保證線程安全)
    private final ConcurrentMap<String, Cache> cacheMap = new ConcurrentHashMap<>(16);
    @Override
    public Cache getCache(String name, MultiCacheConfig config) {
        // 雙重檢查鎖:避免重復(fù)創(chuàng)建緩存
        Cache cache = cacheMap.get(name);
        if (cache != null) {
            return cache;
        }
        synchronized (cacheMap) {
            cache = cacheMap.get(name);
            if (cache == null) {
                // 創(chuàng)建緩存實例(子類實現(xiàn)具體緩存類型)
                cache = createCache(name, config);
                cacheMap.put(name, cache);
            }
            return cache;
        }
    }
    // 抽象方法:由子類實現(xiàn)緩存創(chuàng)建邏輯
    protected abstract Cache createCache(String name, MultiCacheConfig config);
}

4. 分布式鎖組件(Redisson)

解決并發(fā)場景下的緩存問題,核心 API:

public interface DistributedLocker {
    // 獲取單個鎖
    boolean lock(String lockKey, long leaseTime, long waitTime, TimeUnit unit);
    // 獲取聯(lián)鎖(多個Key)
    boolean multiLock(Collection<String> lockKeys, long leaseTime, long waitTime, TimeUnit unit);
    // 釋放鎖
    void unlock(String lockKey);
    // 釋放聯(lián)鎖
    void multiUnlock(Collection<String> lockKeys);
}
// 工具類封裝(靜態(tài)調(diào)用)
public class DistributedLockUtils {
    private static DistributedLocker locker;
    // 獲取鎖并執(zhí)行邏輯
    public static <T> T executeWithLock(String lockKey, long leaseTime, long waitTime, TimeUnit unit, Supplier<T> supplier) {
        if (locker.lock(lockKey, leaseTime, waitTime, unit)) {
            try {
                return supplier.get();
            } finally {
                locker.unlock(lockKey);
            }
        }
        throw new RuntimeException("獲取鎖失敗");
    }
}

5. 工具類

5.1 JSON 序列化工具(JsonUtils)

public class JsonUtils {
    private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper()
        .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    // 對象轉(zhuǎn)JSON字符串
    public static String toJson(Object obj) {
        try {
            return OBJECT_MAPPER.writeValueAsString(obj);
        } catch (JsonProcessingException e) {
            throw new RuntimeException("JSON序列化失敗", e);
        }
    }
    // JSON字符串轉(zhuǎn)對象
    public static <T> T fromJson(String json, Class<T> clazz) {
        try {
            return OBJECT_MAPPER.readValue(json, clazz);
        } catch (JsonProcessingException e) {
            throw new RuntimeException("JSON反序列化失敗", e);
        }
    }
}

5.2 SpEL 表達(dá)式解析工具(CacheExpressionEvaluator)

public class CacheExpressionEvaluator extends CachedExpressionEvaluator {
    private final Map<ExpressionKey, Expression> keyCache = new ConcurrentHashMap<>(64);
    // 創(chuàng)建表達(dá)式上下文(包含方法、參數(shù)、目標(biāo)對象等)
    public EvaluationContext createContext(Method method, Object[] args, Object target) {
        CacheExpressionRootObject root = new CacheExpressionRootObject(method, args, target);
        return new MethodBasedEvaluationContext(root, method, args, getParameterNameDiscoverer());
    }
    // 解析SpEL表達(dá)式
    public Object evaluateKey(String keyExpr, Method method, Object[] args, Object target) {
        if (StringUtils.isEmpty(keyExpr)) {
            return "";
        }
        EvaluationContext context = createContext(method, args, target);
        ExpressionKey key = new ExpressionKey(keyExpr, method);
        return keyCache.computeIfAbsent(key, k -> getExpressionParser().parseExpression(keyExpr))
            .getValue(context);
    }
}

五、進(jìn)階配置與最佳實踐

1. 緩存策略配置

1.1 過期模式選擇

// 過期模式枚舉
public enum ExpireMode {
    WRITE, // 寫入后開始計時(適合寫少讀多場景)
    ACCESS // 訪問后刷新過期時間(適合熱點數(shù)據(jù))
}
// 配置示例:熱點數(shù)據(jù)使用ACCESS模式
MultiCacheConfig hotDataConfig = new MultiCacheConfig();
hotDataConfig.setExpireMode(ExpireMode.ACCESS.name());
hotDataConfig.setTtl(10); // 10分鐘
hotDataConfig.setEnableFirstCache(true);

1.2 防止緩存雪崩

// 配置過期時間隨機(jī)偏移(避免大量Key同時過期)
public class MultiCacheConfig {
    // 最大偏移比例(10%)
    private static final double MAX_OFFSET_RATIO = 0.1;
    // 獲取帶隨機(jī)偏移的過期時間(秒)
    public long getRandomTtl() {
        long baseTtl = getTtlToSeconds();
        double offset = baseTtl * MAX_OFFSET_RATIO;
        // 隨機(jī)增減偏移量
        return (long) (baseTtl + (Math.random() * 2 * offset - offset));
    }
}

2. 性能調(diào)優(yōu)

2.1 本地緩存(Caffeine)調(diào)優(yōu)

// 高性能配置:基于訪問頻率和過期時間
CaffeineCacheConfig config = new CaffeineCacheConfig();
config.setInitialCapacity(100); // 初始容量
config.setMaximumSize(5000); // 最大容量(避免內(nèi)存溢出)
config.setExpireMode(ExpireMode.ACCESS); // 訪問過期
config.setTtl(5); // 5分鐘過期

2.2 Redis 緩存調(diào)優(yōu)

spring:
  redis:
    lettuce:
      pool:
        max-active: 16 # 最大連接數(shù)
        max-idle: 8 # 最大空閑連接
        min-idle: 4 # 最小空閑連接
    timeout: 2000ms # 超時時間(避免長時間阻塞)

3. 常見問題解決方案

3.1 緩存穿透(查詢不存在的數(shù)據(jù))

// 方案:緩存NULL值 + 分布式鎖
public User getUserById(Long userId) {
    String cacheKey = "user:" + userId;
    Cache cache = cacheManager.getCache("userCache", config);
    // 1. 查緩存(包括NULL值)
    User user = cache.get(cacheKey, User.class);
    if (user != null) {
        return user;
    }
    // 2. 分布式鎖:防止并發(fā)查詢不存在的數(shù)據(jù)
    return DistributedLockUtils.executeWithLock(
        "lock:user:" + userId, 5, 3, TimeUnit.SECONDS,
        () -> {
            // 3. 再次查緩存(避免鎖等待期間已緩存)
            User cachedUser = cache.get(cacheKey, User.class);
            if (cachedUser != null) {
                return cachedUser;
            }
            // 4. 查庫(不存在則返回null)
            User dbUser = userDao.selectById(userId);
            // 5. 緩存結(jié)果(包括NULL值)
            cache.put(cacheKey, dbUser);
            return dbUser;
        }
    );
}

3.2 緩存擊穿(熱點Key過期)

// 方案:緩存自動續(xù)期 + 分布式鎖
public Product getHotProduct(Long productId) {
    String cacheKey = "hot:product:" + productId;
    Cache cache = cacheManager.getCache("hotProductCache", config);
    return DistributedLockUtils.executeWithLock(
        cacheKey + ":lock", -1, 3, TimeUnit.SECONDS, // leaseTime=-1:自動續(xù)期
        () -> {
            Product product = cache.get(cacheKey, Product.class);
            if (product != null) {
                // 訪問后刷新過期時間(ACCESS模式自動實現(xiàn))
                return product;
            }
            // 查庫并緩存
            Product dbProduct = productDao.selectById(productId);
            cache.put(cacheKey, dbProduct);
            return dbProduct;
        }
    );
}

3.3 緩存一致性(更新/刪除后同步緩存)

// 方案:更新數(shù)據(jù)庫后同步更新緩存,刪除數(shù)據(jù)庫后刪除緩存
@Transactional
public void updateProduct(Product product) {
    // 1. 更新數(shù)據(jù)庫(事務(wù)內(nèi))
    productDao.updateById(product);
    // 2. 更新緩存(事務(wù)提交后執(zhí)行,避免事務(wù)回滾導(dǎo)致緩存臟數(shù)據(jù))
    TransactionSynchronizationManager.registerSynchronization(
        new TransactionSynchronizationAdapter() {
            @Override
            public void afterCommit() {
                Cache cache = cacheManager.getCache("productCache", config);
                cache.put("product:" + product.getId(), product);
            }
        }
    );
}

六、完整可復(fù)用核心代碼

1. 緩存配置類

import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.beans.factory.annotation.Value;
@Configuration
@ConditionalOnBean(RedisTemplate.class)
public class CacheAutoConfiguration {
    @Value("${spring.application.name}")
    private String appName;
    // 注冊緩存管理器
    @Bean
    public CacheManager cacheManager(RedisTemplate<String, String> redisTemplate) {
        return new DefaultCacheManager(appName, new RedisCacheTemplate(redisTemplate));
    }
    // 注冊分布式鎖
    @Bean
    public DistributedLocker distributedLocker(RedissonClient redissonClient) {
        return new RedissonDistributedLocker(redissonClient);
    }
}

2. 多級緩存配置模型

import java.util.concurrent.TimeUnit;
public class MultiCacheConfig {
    // 緩存過期時間(默認(rèn)10分鐘)
    private long ttl = 10;
    // 時間單位(默認(rèn)分鐘)
    private TimeUnit timeUnit = TimeUnit.MINUTES;
    // 過期時間比例(用于動態(tài)調(diào)整,1-100)
    private int ttlProportion = 10;
    // 是否緩存NULL值(默認(rèn)false)
    private boolean cacheNullValues = false;
    // 是否啟用本地緩存(默認(rèn)false)
    private boolean enableLocalCache = false;
    // 本地緩存初始容量(默認(rèn)10)
    private int initialCapacity = 10;
    // 本地緩存最大容量(默認(rèn)3000)
    private long maximumSize = 3000;
    // 過期模式(默認(rèn)WRITE)
    private String expireMode = ExpireMode.WRITE.name();
    // Getter/Setter 省略
    // 轉(zhuǎn)換為秒級過期時間
    public long getTtlToSeconds() {
        return timeUnit.toSeconds(ttl);
    }
    // 帶比例的過期時間(最小3秒)
    public long getTtlWithProportion() {
        long base = getTtlToSeconds();
        long proportioned = (base * ttlProportion) / 100;
        return Math.max(proportioned, 3);
    }
}
// 過期模式枚舉
enum ExpireMode {
    WRITE, ACCESS
}

3. 空值標(biāo)識類

import java.io.Serializable;
public class NullValue implements Serializable {
    private static final long serialVersionUID = 1L;
    public static final NullValue INSTANCE = new NullValue();
    private NullValue() {}
    // 反序列化時返回單例
    private Object readResolve() {
        return INSTANCE;
    }
    @Override
    public boolean equals(Object obj) {
        return obj == this || obj == null;
    }
    @Override
    public int hashCode() {
        return NullValue.class.hashCode();
    }
    // 判斷是否為空值
    public static boolean isNull(Object value) {
        return value == null || value == INSTANCE;
    }
}

4. Redis 緩存模板

import org.springframework.data.redis.core.StringRedisTemplate;
import java.util.concurrent.TimeUnit;
public class RedisCacheTemplate {
    private final StringRedisTemplate redisTemplate;
    public RedisCacheTemplate(StringRedisTemplate redisTemplate) {
        this.redisTemplate = redisTemplate;
    }
    // 設(shè)置緩存(帶過期時間)
    public void set(String key, String value, long ttl, TimeUnit unit) {
        redisTemplate.opsForValue().set(key, value, ttl, unit);
    }
    // 獲取緩存
    public String get(String key) {
        return redisTemplate.opsForValue().get(key);
    }
    // 刪除緩存
    public boolean delete(String key) {
        return redisTemplate.delete(key);
    }
    // 批量刪除
    public long delete(Collection<String> keys) {
        return redisTemplate.delete(keys);
    }
    // 判斷Key是否存在
    public boolean hasKey(String key) {
        return redisTemplate.hasKey(key);
    }
    // 設(shè)置過期時間
    public boolean expire(String key, long ttl, TimeUnit unit) {
        return redisTemplate.expire(key, ttl, unit);
    }
}

到此這篇關(guān)于Redis Caffeine多級緩存框架的實現(xiàn)的文章就介紹到這了,更多相關(guān)Redis Caffeine多級緩存內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • 高并發(fā)下Redis如何保持?jǐn)?shù)據(jù)一致性(避免讀后寫)

    高并發(fā)下Redis如何保持?jǐn)?shù)據(jù)一致性(避免讀后寫)

    本文主要介紹了高并發(fā)下Redis如何保持?jǐn)?shù)據(jù)一致性(避免讀后寫),文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-03-03
  • Redis Redisson lock和tryLock的原理分析

    Redis Redisson lock和tryLock的原理分析

    這篇文章主要介紹了Redis Redisson lock和tryLock的原理分析,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-04-04
  • 使用Redis有序集合實現(xiàn)IP歸屬地查詢詳解

    使用Redis有序集合實現(xiàn)IP歸屬地查詢詳解

    這篇文章主要介紹了使用Redis有序集合實現(xiàn)IP歸屬地查詢,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-04-04
  • Redis Cluster添加、刪除的完整操作步驟

    Redis Cluster添加、刪除的完整操作步驟

    這篇文章主要給大家介紹了關(guān)于Redis Cluster添加、刪除的完整操作步驟,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)下吧。
    2017-09-09
  • 簡單聊一聊redis過期時間的問題

    簡單聊一聊redis過期時間的問題

    在使用redis的過期時間時不由想到設(shè)置了過期時間,下面這篇文章主要給大家介紹了關(guān)于redis過期時間問題的相關(guān)資料,文中通過實例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2023-04-04
  • 分割超大Redis數(shù)據(jù)庫例子

    分割超大Redis數(shù)據(jù)庫例子

    這篇文章主要介紹了分割超大Redis數(shù)據(jù)庫例子,本文講解了分割的需求、分割的思路及分割實例,需要的朋友可以參考下
    2015-03-03
  • Redis數(shù)據(jù)結(jié)構(gòu)之listpack和quicklist使用學(xué)習(xí)

    Redis數(shù)據(jù)結(jié)構(gòu)之listpack和quicklist使用學(xué)習(xí)

    這篇文章主要為大家介紹了Redis數(shù)據(jù)結(jié)構(gòu)之listpack和quicklist的使用學(xué)習(xí),有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-07-07
  • Redis通過scan查找不過期的 key(方法詳解)

    Redis通過scan查找不過期的 key(方法詳解)

    SCAN 命令是一個基于游標(biāo)的迭代器,每次被調(diào)用之后, 都會向用戶返回一個新的游標(biāo), 用戶在下次迭代時需要使用這個新游標(biāo)作為 SCAN 命令的游標(biāo)參數(shù), 以此來延續(xù)之前的迭代過程,對Redis scan 查找 key相關(guān)知識感興趣的朋友一起看看吧
    2021-08-08
  • 詳解centos7 yum安裝redis及常用命令

    詳解centos7 yum安裝redis及常用命令

    這篇文章主要介紹了centos7 yum安裝redis及常用命令,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-09-09
  • Redis key鍵的具體使用

    Redis key鍵的具體使用

    Redis 是一種鍵值(key-value)型的緩存型數(shù)據(jù)庫,它將數(shù)據(jù)全部以鍵值對的形式存儲在內(nèi)存中,本文就來介紹一下key鍵的具體使用,感興趣的可以了解一下
    2024-02-02

最新評論

丽江市| 永定县| 卢湾区| 磴口县| 长武县| 拉萨市| 嘉荫县| 厦门市| 应城市| 都匀市| 承德市| 吉木乃县| 潼南县| 黄平县| 河源市| 高碑店市| 呼玛县| 依兰县| 慈利县| 鄱阳县| 宁海县| 河南省| 北海市| 晋宁县| 东莞市| 策勒县| 巴马| 徐州市| 泗洪县| 靖远县| 台中县| 手游| 原平市| 云南省| 扬中市| 剑川县| 永城市| 元阳县| 乐业县| 呼图壁县| 上杭县|