Working with Sets
Working with Setsset相关的命令:
SADD: 给set增加N个成员,数组或者单个元素
SREM: 从数组中移除单个或者一个成员
SISMEMBER: 判断成员是否存在
SMEMBERS: 获取set中所有成员
sadd($key, ';china';); $redis->sadd($key, ['england', 'france', 'germany']); $redis->sadd($key, 'china'); // this entry is ignored $redis->srem($key, ['england', 'china']); $redis->sismember($key, 'england'); // false $redis->smembers($key); // ['france', 'germany']
Set Expiry and Persistence
Set Expiry and Persistence因为Resia在内存中存储,你可能并不像永久存储,就比如我之前的介绍Node创建session的文章. 这里可以设置过期的方法有 EXPIRE, EXPIREAT, TTL, PERSIST –
EXPIRE: 以秒为单位,设置过期时间
EXPIREAT: 过多久之后被删除,以秒为单位
TTL:距离过期还剩多少时间
PERSIST:让一个键永久保存
$key = "expire in 1 hour"; $redis->expire($key, 3600); // expires in 1 hour $redis->expireat($key, time() + 3600); // expires in 1 hour sleep(600); // don't try this, just an illustration for time spent $redis->ttl($key); // 3000, ergo expires in 50 minutes $redis->persist($key); // this will never expire.
CONCLUSION
CONCLUSION后悔中......花了30分钟,翻译了这么一篇没水平的文章,也不知道自己是怎么想的。越想越不对,但是既然翻译了,就翻译完了,里面可能有翻译的不对的地方,或者代码错误的地方,那都不是问题,掠过就可以。
Future of Redis
Future of RedisRedis is a better replacement for memcached, as it is faster, scales better (supports master-slave replication), supports datatypes that many (Facebook, Twitter, Instagram) have dropped memcached for Redis. Redis is open source and many brilliant programmers from the open-source community have contributed patches.