赞
踩
put:put的话是会全部覆盖之前的数据,所以我们如果只是想更新Redis中一个对象的一个字段时,最好保证新对象中其它字段都是之前的值,这样就不会有数据丢失了。
putIfAbsent:这个方法会判断key是否有值,如果没有就直接插入,返回true;如果有值的话就不会插入,返回false。
- //
- // Source code recreated from a .class file by IntelliJ IDEA
- // (powered by FernFlower decompiler)
- //
-
- package org.springframework.data.redis.core;
-
- import java.util.Collection;
- import java.util.List;
- import java.util.Map;
- import java.util.Set;
- import java.util.Map.Entry;
- import org.springframework.lang.Nullable;
-
- public interface HashOperations<H, HK, HV> {
- Long delete(H key, Object... hashKeys);
-
- Boolean hasKey(H key, Object hashKey);
-
- @Nullable
- HV get(H key, Object hashKey);
-
- List<HV> multiGet(H key, Collection<HK> hashKeys);
-
- Long increment(H key, HK hashKey, long delta);
-
- Double increment(H key, HK hashKey, double delta);
-
- @Nullable
- HK randomKey(H key);
-
- @Nullable
- Entry<HK, HV> randomEntry(H key);
-
- @Nullable
- List<HK> randomKeys(H key, long count);
-
- @Nullable
- Map<HK, HV> randomEntries(H key, long count);
-
- Set<HK> keys(H key);
-
- @Nullable
- Long lengthOfValue(H key, HK hashKey);
-
- Long size(H key);
-
- void putAll(H key, Map<? extends HK, ? extends HV> m);
-
- void put(H key, HK hashKey, HV value);
-
- Boolean putIfAbsent(H key, HK hashKey, HV value);
-
- List<HV> values(H key);
-
- Map<HK, HV> entries(H key);
-
- Cursor<Entry<HK, HV>> scan(H key, ScanOptions options);
-
- RedisOperations<H, ?> getOperations();
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。