摘要:原文地址下載安裝版是上的一個開源項目我們可以直接下載解壓使用。通過快捷方式啟動服務(wù)修改的默認配置設(shè)置的最大占用內(nèi)存設(shè)置最大占用內(nèi)存,打開配置文件,找到如下段落,設(shè)置參數(shù),是字節(jié)類型,注意轉(zhuǎn)換。是近期最少使用算法。
原文地址
下載安裝Redis--Window版是GitHub上的一個開源項目我們可以直接下載解壓使用。
Download Now
在D盤下新建Redis文件(這個路徑可以自定義),將Redis解壓至該文件
安裝完后 打開 win控制臺 cd 進入 Redis 目錄
運行:redis-server.exe redis.windows.conf
如果出現(xiàn)以下信息則說明安裝成功。
配置之前先關(guān)掉Redis服務(wù)
添加啟動Redis的快捷方式為redis-server.exe創(chuàng)建快捷方式redis(名字 自定義)
修改redis的屬性,為redis的目標屬性,加入并指定讀取的配置文件redis.windows.conf,前面要加空格。
通過快捷方式redis啟動Redis服務(wù)
修改Redis的默認配置 設(shè)置Redis的最大占用內(nèi)存Redis設(shè)置最大占用內(nèi)存,打開redis配置文件,找到如下段落,設(shè)置maxmemory參數(shù),maxmemory是bytes字節(jié)類型,注意轉(zhuǎn)換。修改如下所示:
# NOTE: since Redis uses the system paging file to allocate the heap memory, # the Working Set memory usage showed by the Windows Task Manager or by other # tools such as ProcessExplorer will not always be accurate. For example, right # after a background save of the RDB or the AOF files, the working set value # may drop significantly. In order to check the correct amount of memory used # by the redis-server to store the data, use the INFO client command. The INFO # command shows only the memory used to store the redis data, not the extra # memory used by the Windows process for its own requirements. Th3 extra amount # of memory not reported by the INFO command can be calculated subtracting the # Peak Working Set reported by the Windows Task Manager and the used_memory_peak # reported by the INFO command. # # maxmemory根據(jù)自己需求配置 maxmemory 2147483648
如果不設(shè)置maxmemory或者設(shè)置為0,64位系統(tǒng)不限制內(nèi)存,32位系統(tǒng)最多使用3GB內(nèi)存。
修改數(shù)據(jù)默認存放位置這里自定義一個文件夾,用來存放Redis數(shù)據(jù)
# The working directory. # # The DB will be written inside this directory, with the filename specified # above using the "dbfilename" configuration directive. # # The Append Only File will also be created inside this directory. # # Note that you must specify a directory here, not a file name. dir D:MyRedisSwap設(shè)置LRU算法刪除數(shù)據(jù)
設(shè)置了maxmemory的選項,redis內(nèi)存使用達到上限??梢酝ㄟ^設(shè)置LRU算法來刪除部分key,釋放空間。默認是按照過期時間的,如果set時候沒有加上過期時間就會導(dǎo)致數(shù)據(jù)寫滿maxmemory。
LRU是Least Recently Used 近期最少使用算法。
volatile-lru -> 根據(jù)LRU算法生成的過期時間來刪除。
-allkeys-lru -> 根據(jù)LRU算法刪除任何key。
volatile-random -> 根據(jù)過期設(shè)置來隨機刪除key。
allkeys->random -> 無差別隨機刪。
volatile-ttl -> 根據(jù)最近過期時間來刪除(輔以TTL)
noeviction -> 誰也不刪,直接在寫操作時返回錯誤。
如果設(shè)置了maxmemory,一般都要設(shè)置過期策略。Redis默認有六種過期策略
# MAXMEMORY POLICY: how Redis will select what to remove when maxmemory # is reached. You can select among five behaviors: # # volatile-lru -> remove the key with an expire set using an LRU algorithm # allkeys-lru -> remove any key according to the LRU algorithm # volatile-random -> remove a random key with an expire set # allkeys-random -> remove a random key, any key # volatile-ttl -> remove the key with the nearest expire time (minor TTL) # noeviction -> don"t expire at all, just return an error on write operations # # Note: with any of the above policies, Redis will return an error on write # operations, when there are no suitable keys for eviction. # # At the date of writing these commands are: set setnx setex append # incr decr rpush lpush rpushx lpushx linsert lset rpoplpush sadd # sinter sinterstore sunion sunionstore sdiff sdiffstore zadd zincrby # zunionstore zinterstore hset hsetnx hmset hincrby incrby decrby # getset mset msetnx exec sort # # The default is: # # maxmemory-policy noeviction maxmemory-policy volatile-lru
以下是其他配置:
Redis默認不是以守護進程的方式運行,可以通過該配置項修改,使用yes啟用守護進程 (在Windows上不支持守護進程)
daemonize no
指定Redis監(jiān)聽端口,默認端口為6379
(在Windows上不支持守護進程)
port 6379
綁定的主機地址
bind 127.0.0.1
指定在多長時間內(nèi),有多少次更新操作,就將數(shù)據(jù)同步到數(shù)據(jù)文件,可以多個條件配合
save
Redis默認配置文件中提供了三個條件:
save 900 1 save 300 10 save 60 10000
分別表示900秒(15分鐘)內(nèi)有1個更改,300秒(5分鐘)內(nèi)有10個更改以及60秒內(nèi)有10000個更改。
指定更新日志文件名,默認為appendonly.aof
appendfilename appendonly.aof
指定更新日志條件,共有3個可選值:
no:表示等操作系統(tǒng)進行數(shù)據(jù)緩存同步到磁盤(快) always:表示每次更新操作后手動調(diào)用fsync()將數(shù)據(jù)寫到磁盤(慢,安全) everysec:表示每秒同步一次(折衷,默認值) appendfsync everysec
指定在超過一定的數(shù)量或者最大的元素超過某一臨界值時,采用一種特殊的哈希算法
hash-max-zipmap-entries 64 hash-max-zipmap-value 512
參考鏈接:
Redis中文網(wǎng)
文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請注明本文地址:http://www.ezyhdfw.cn/yun/69248.html
摘要:第步配置環(huán)境變量在中使用即可,不用寫第步輸入進入中,輸入檢驗是否安裝成功。安裝服務(wù)啟動服務(wù)停止服務(wù)切換到目錄下運行參考安裝解壓,配置環(huán)境變量,下開啟和關(guān)閉窗口方式啟動安裝服務(wù)啟動協(xié)助服務(wù)命令校驗是否啟動輸入?yún)⒖? 1.安裝jdk 第1步:在官網(wǎng)下載和自己電腦位數(shù)相同的安裝包 第2步:選擇安裝路徑,默認在C盤,建議自定義選擇其他盤符,避免c盤重裝系統(tǒng)后,需要重新安裝。 第3步:安裝過程中...
摘要:整體與很像,但是做了一些更改,為了更適應(yīng)中國國內(nèi)的開發(fā)網(wǎng)絡(luò)環(huán)境。表示宿主機器的目錄,表示環(huán)境目錄。將虛擬機置于休眠狀態(tài)。在開發(fā)過程中可能會需要增加多個站點來運行不同的開發(fā)程序。與擴展名重名,建議將的改成為佳。 SimfaseDevEnv 介紹 SimfaseDevEnv是為php開發(fā)者提供的開發(fā)環(huán)境,構(gòu)建在vagrant之上;Vagrant的Vagrangfile配置文件是在Homes...
閱讀 7245·2021-09-22 15:36
閱讀 6047·2021-09-02 10:20
閱讀 1936·2019-08-30 15:44
閱讀 2723·2019-08-29 14:06
閱讀 1217·2019-08-29 11:17
閱讀 1671·2019-08-26 14:05
閱讀 3234·2019-08-26 13:50
閱讀 1618·2019-08-26 10:26