Is DefaultHashOperations and so on thread safe in RedisTemplate?

    public <HK, HV> HashOperations<K, HK, HV> opsForHash() {
        return new DefaultHashOperations(this);
    }

A new DefaultHashOperations is generated every time I use opsForHash ()
if only one DefaultHashOperations is generated in a RedisUtil and this one is called every time, what"s the problem? Are
DefaultHashOperations,DefaultSetOperations and so on thread safe?

@Component
public final class RedisUtil {
    private HashOperations<String, Object, Object> hashOperations; 

    @Autowired
    private RedisTemplate<String, Object> redisTemplate;

    @PostConstruct
    void init(){
        hashOperations = redisTemplate.opsForHash();
    }

    public Set<Object> allFields(String key) {
        return redisTemplate.opsForHash().keys(key);
    }


    public List<Object> allValues(String key) {
        return redisTemplate.opsForHash().values(key);
    }
}

Jun.11,2022

should be said to be thread-safe, because the data shared by DefaultHashOperations is RedisTemplate, and this member variable is Once configured, this class is thread-safe. , that is, it is thread-safe once configured.

but in fact, the construction of DefaultHashOperations is lightweight, and considering that the extension implementation of RedisTemplate may be different, it is not necessary to do caching, but it is not convenient to extend.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3c531-2c2e8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3c531-2c2e8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?