我们有很多 Redis 实例,消耗 TB 内存和数百台机器。
随着我们业务活动的起起落落,一些 Redis 实例不再那么频繁地使用了——它们“不受欢迎”或“冷”。但是 Redis 将所有内容都存储在内存中,因此许多本应存储在廉价磁盘中的不常用数据正在占用昂贵的内存。
我们正在探索一种从这些不受欢迎/冷的 Redis 中节省内存的方法,以减少我们的机器使用率。
我们不能删除数据,也不能迁移到其他数据库。有什么方法可以实现我们的目标吗?
PS:我们正在考虑一些Redis兼容产品,可以“混合”内存和磁盘,即热数据存储在内存中,冷数据存储在磁盘中,并且使用有限资源。我们知道RedisLabs的“Redis on Flash(ROF)”解决方案,但它使用的是RocksDB,对内存非常不友好。我们想要的是一个非常受内存限制的产品。此外,ROF 不是开源的 :(
提前致谢!
JDK7中ConcurrentHashMap中的scanAndLockForPut方法的源代码说:
private HashEntry<K,V> scanAndLockForPut(K key, int hash, V value) {
HashEntry<K,V> first = entryForHash(this, hash);
HashEntry<K,V> e = first;
HashEntry<K,V> node = null;
int retries = -1; // negative while locating node
while (!tryLock()) {
HashEntry<K,V> f; // to recheck first below
if (retries < 0) {
if (e == null) {
if (node == null) // speculatively create node
node = new HashEntry<K,V>(hash, key, value, null);
retries = 0;
}
else if (key.equals(e.key))
retries = 0;
else …Run Code Online (Sandbox Code Playgroud) 我尝试在osx yosemite(10.10.4)下制作gunplot 5.0.0,它带有错误:
$ make
/Applications/Xcode.app/Contents/Developer/usr/bin/make all-recursive
Making all in config
make[2]: Nothing to be done for `all'.
Making all in m4
make[2]: Nothing to be done for `all'.
Making all in term
make[2]: Nothing to be done for `all'.
Making all in src
/Applications/Xcode.app/Contents/Developer/usr/bin/make all-recursive
Making all in wxterminal
make[4]: Nothing to be done for `all'.
Making all in qtterminal
make[4]: Nothing to be done for `all'.
c++ -g -O2 -o gnuplot alloc.o axis.o breaders.o boundary.o color.o command.o contour.o …Run Code Online (Sandbox Code Playgroud) 我刚刚在 Rust 中遇到了以下代码:
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
fn main() {
let mut v1 = vec![HashMap::<i32, i32>::new(); 2];
v1[0].insert(0,0);
v1[1].insert(1,1);
println!("{:?}", v1);
let v2 = vec![Arc::new(Mutex::new(HashMap::<i32, i32>::new())); 2];
v2[0].lock().unwrap().insert(0,0);
v2[1].lock().unwrap().insert(1,1);
println!("{:?}", v2);
}
// outputs:
// [{0: 0}, {1: 1}]
// [Mutex { data: {0: 0, 1: 1} }, Mutex { data: {0: 0, 1: 1} }]
Run Code Online (Sandbox Code Playgroud)
它显然v1有 2 个不同的 HashMap,而v2只有一个。这是怎么回事?不应该v2评估Arc::new(Mutex::new(HashMap::<i32, i32>::new()))两次(就像v1do)从而创建两个不同的元素?这是某种“懒惰”的评估吗?
请原谅我的 rust 新手问题,提前致谢!