Skip to content

Commit

Permalink
将『设计模式』改成『模式』,并修正样式
Browse files Browse the repository at this point in the history
  • Loading branch information
huangzworks committed Mar 25, 2012
1 parent 2a7677e commit 03785c6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
6 changes: 2 additions & 4 deletions string/append.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ APPEND
redis> GET myphone # 查看整个字符串
"nokia - 1110"

**模式:时间序列(Time series)**
模式:时间序列(Time series)
------------------------------

`APPEND`_ 可以为一系列定长(fixed-size)数据(sample)提供一种紧凑的表示方式,通常称之为时间序列。

Expand Down Expand Up @@ -69,6 +70,3 @@ APPEND

redis> GET mykey
"Hello World"



3 changes: 2 additions & 1 deletion string/getset.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ GETSET
redis> GETSET mail [email protected] # mail被更新,旧值被返回
"[email protected]"

**设计模式**
模式
--------

\ `GETSET`_\ 可以和\ `INCR`_\ 组合使用,实现一个有原子性(atomic)复位操作的计数器(counter)。

Expand Down
3 changes: 2 additions & 1 deletion string/setnx.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ SETNX
redis> GET job # 没有被覆盖
"programmer"

**设计模式(Design pattern): 将SETNX用于加锁(locking)**
模式:将SETNX用于加锁(locking)
----------------------------------------

\ `SETNX`_\ 可以用作加锁原语(locking primitive)。比如说,要对关键字(key)\ ``foo``\ 加锁,客户端可以尝试以下方式:

Expand Down
9 changes: 5 additions & 4 deletions string/setrange.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ SETRANGE
设置偏移量为134217728(128MB内存分配),耗费约80毫秒,设置偏移量33554432(32MB内存分配),耗费约30毫秒,设置偏移量为8388608(8MB内存分配),耗费约8毫秒。
注意若首次内存分配成功之后,再对同一个\ ``key``\ 调用\ `SETRANGE`_\ 操作,无须再重新内存。

**模式**

因为有了\ `SETRANGE`_\ \ `GETRANGE`_\ 命令,你可以将Redis字符串用作具有O(1)随机访问时间的线性数组。这在很多真实用例中都是非常快速且高效的储存方式。

::

# 情况1:对非空字符串进行SETRANGE
Expand All @@ -54,4 +50,9 @@ SETRANGE
redis> GET empty_string # 空白处被"\x00"填充
"\x00\x00\x00\x00\x00Redis!"

模式
-------

因为有了\ `SETRANGE`_\ \ `GETRANGE`_\ 命令,你可以将Redis字符串用作具有O(1)随机访问时间的线性数组。这在很多真实用例中都是非常快速且高效的储存方式。


0 comments on commit 03785c6

Please sign in to comment.