<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ko">
	<id>https://devcafe.co.kr/w/index.php?action=history&amp;feed=atom&amp;title=Python_redis_sample</id>
	<title>Python redis sample - 편집 역사</title>
	<link rel="self" type="application/atom+xml" href="https://devcafe.co.kr/w/index.php?action=history&amp;feed=atom&amp;title=Python_redis_sample"/>
	<link rel="alternate" type="text/html" href="https://devcafe.co.kr/w/index.php?title=Python_redis_sample&amp;action=history"/>
	<updated>2026-11-17T07:28:35Z</updated>
	<subtitle>이 문서의 편집 역사</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://devcafe.co.kr/w/index.php?title=Python_redis_sample&amp;diff=2819&amp;oldid=prev</id>
		<title>Devcafe: 개발노트 양식 일괄 적용</title>
		<link rel="alternate" type="text/html" href="https://devcafe.co.kr/w/index.php?title=Python_redis_sample&amp;diff=2819&amp;oldid=prev"/>
		<updated>2026-11-12T03:44:33Z</updated>

		<summary type="html">&lt;p&gt;개발노트 양식 일괄 적용&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ko&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← 이전 판&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;2026년 11월 12일 (목) 12:44 판&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;1번째 줄:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;1번째 줄:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;{{개발노트&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;|요약=python redis example&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;|핵심=&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;|분야=Python&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;|작성일=2024-10-04&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;}}&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;기타&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;기타&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Devcafe</name></author>
	</entry>
	<entry>
		<id>https://devcafe.co.kr/w/index.php?title=Python_redis_sample&amp;diff=31&amp;oldid=prev</id>
		<title>Devcafe: 새 문서:  기타 python redis example 세모데 2017.03.26 17:24 댓글수0 공감수 0 # -*- coding:utf-8 -*-     import sys, random, time from redis import Redis, exceptions, RedisError from redis.sentinel import (Sentinel, SentinelConnectionPool,ConnectionError,                             MasterNotFoundError, SlaveNotFoundError)     # Redis 접속 기본 설정값 listSentinel = [(&#039;10.0.10.1&#039;, 26379), (&#039;10.0.10.2&#039;, 26379), (&#039;10.0.10.3&#039;, 26379), (&#039;10.0.0.2&#039;, 26379)] strServiceName = &#039;...</title>
		<link rel="alternate" type="text/html" href="https://devcafe.co.kr/w/index.php?title=Python_redis_sample&amp;diff=31&amp;oldid=prev"/>
		<updated>2024-10-04T15:20:10Z</updated>

		<summary type="html">&lt;p&gt;새 문서:  기타 python redis example 세모데 2017.03.26 17:24 댓글수0 공감수 0 # -*- coding:utf-8 -*-     import sys, random, time from redis import Redis, exceptions, RedisError from redis.sentinel import (Sentinel, SentinelConnectionPool,ConnectionError,                             MasterNotFoundError, SlaveNotFoundError)     # Redis 접속 기본 설정값 listSentinel = [(&amp;#039;10.0.10.1&amp;#039;, 26379), (&amp;#039;10.0.10.2&amp;#039;, 26379), (&amp;#039;10.0.10.3&amp;#039;, 26379), (&amp;#039;10.0.0.2&amp;#039;, 26379)] strServiceName = &amp;#039;...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;새 문서&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
기타&lt;br /&gt;
python redis example&lt;br /&gt;
세모데&lt;br /&gt;
2017.03.26 17:24 댓글수0 공감수 0&lt;br /&gt;
# -*- coding:utf-8 -*-&lt;br /&gt;
   &lt;br /&gt;
import sys, random, time&lt;br /&gt;
from redis import Redis, exceptions, RedisError&lt;br /&gt;
from redis.sentinel import (Sentinel, SentinelConnectionPool,ConnectionError,&lt;br /&gt;
                            MasterNotFoundError, SlaveNotFoundError)&lt;br /&gt;
   &lt;br /&gt;
# Redis 접속 기본 설정값&lt;br /&gt;
listSentinel = [(&amp;#039;10.0.10.1&amp;#039;, 26379), (&amp;#039;10.0.10.2&amp;#039;, 26379), (&amp;#039;10.0.10.3&amp;#039;, 26379), (&amp;#039;10.0.0.2&amp;#039;, 26379)]&lt;br /&gt;
strServiceName = &amp;#039;stn-master&amp;#039;&lt;br /&gt;
strRedisPass = &amp;#039;1234&amp;#039;&lt;br /&gt;
nDB = 0&lt;br /&gt;
   &lt;br /&gt;
nMaxUser = 1000&lt;br /&gt;
   &lt;br /&gt;
sentinel = Sentinel(listSentinel, socket_timeout=0.1)&lt;br /&gt;
try:&lt;br /&gt;
    #sentinel.discover_master(strServiceName) # No need for this&lt;br /&gt;
    #sentinel.discover_slaves(strServiceName)&lt;br /&gt;
    master = sentinel.master_for(strServiceName, password=strRedisPass, db=nDB, socket_timeout=0.1)&lt;br /&gt;
    slave = sentinel.slave_for(strServiceName, password=strRedisPass, db=nDB, socket_timeout=0.1)&lt;br /&gt;
   &lt;br /&gt;
except MasterNotFoundError:&lt;br /&gt;
    print &amp;#039;Master not found or Sentinel instances not runnung&amp;#039;&lt;br /&gt;
    sys.exit()&lt;br /&gt;
except SlaveNotFoundError:&lt;br /&gt;
    print &amp;#039;Slave not found or Sentinel instances not runnung&amp;#039;&lt;br /&gt;
    sys.exit()&lt;br /&gt;
except ConnectionError:&lt;br /&gt;
    print &amp;#039;Connection Error. Check if Sentinel instances are running&amp;#039;&lt;br /&gt;
    sys.exit()&lt;br /&gt;
   &lt;br /&gt;
start_time = time.time()&lt;br /&gt;
   &lt;br /&gt;
for n in range(1, nMaxUser):&lt;br /&gt;
    for m in range(1, random.randint(0, 5)):&lt;br /&gt;
        master.hset( &amp;quot;cart.user:&amp;quot;+str(n), random.randint(1, 300), random.randint(1, 5) )&lt;br /&gt;
   &lt;br /&gt;
time_elapsed_1 = time.time() - start_time&lt;br /&gt;
   &lt;br /&gt;
start_time = time.time()&lt;br /&gt;
   &lt;br /&gt;
for n in range(1, nMaxUser):&lt;br /&gt;
    slave.hgetall(&amp;quot;cart.user:&amp;quot;+str(n))&lt;br /&gt;
   &lt;br /&gt;
time_elapsed_2 = time.time() - start_time&lt;br /&gt;
   &lt;br /&gt;
count = 0&lt;br /&gt;
   &lt;br /&gt;
for n in range(1, nMaxUser):&lt;br /&gt;
    data = slave.hgetall(&amp;quot;cart.user:&amp;quot;+str(n))&lt;br /&gt;
    if len(data) &amp;gt; 0:&lt;br /&gt;
        count = count + 1&lt;br /&gt;
        print count, &amp;quot; [Cart.user:&amp;quot;+str(n)+&amp;quot;] &amp;quot;, data&lt;br /&gt;
   &lt;br /&gt;
print &amp;quot;---------------------------------------------------&amp;quot;&lt;br /&gt;
print &amp;quot;[Time for writing]: &amp;quot;, time_elapsed_1, &amp;quot; sec., [Time for reading]: &amp;quot;, time_elapsed_2, &amp;quot; sec.&amp;quot;&lt;br /&gt;
[[Category:python]]&lt;/div&gt;</summary>
		<author><name>Devcafe</name></author>
	</entry>
</feed>