forked from tj/connect-redis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
232 lines (220 loc) · 9.81 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<a href="http://github.com/visionmedia/connect-redis"><img alt="Fork me on GitHub" id="ribbon" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"></a><html>
<head>
<title>Connect Redis</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<style>body {
margin: 0;
padding: 0;
font: 14px/1.5 'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif;
color: #252519;
}
a {
color: #252519;
}
a:hover {
text-decoration: underline;
color: #19469D;
}
p {
margin: 12px 0;
}
h1, h2, h3 {
margin: 0;
padding: 0;
}
table#source {
width: 100%;
border-collapse: collapse;
}
table#source td:first-child {
padding: 30px 40px 30px 40px;
vertical-align: top;
}
table#source td:first-child,
table#source td:first-child pre {
width: 450px;
}
table#source td:last-child {
padding: 30px 0 30px 40px;
border-left: 1px solid #E5E5EE;
background: #F5F5FF;
}
table#source tr {
border-bottom: 1px solid #E5E5EE;
}
table#source tr.filename {
padding-top: 40px;
border-top: 1px solid #E5E5EE;
}
table#source tr.filename td:first-child {
text-transform: capitalize;
}
table#source tr.filename td:last-child {
font-size: 12px;
}
table#source tr.filename h2 {
margin: 0;
padding: 0;
cursor: pointer;
}
table#source tr.code h1,
table#source tr.code h2,
table#source tr.code h3 {
margin-top: 30px;
font-family: "Lucida Grande", "Helvetica Nueue", Arial, sans-serif;
font-size: 18px;
}
table#source tr.code h2 {
font-size: 16px;
}
table#source tr.code h3 {
font-size: 14px;
}
table#source tr.code ul {
margin: 15px 0 15px 35px;
padding: 0;
}
table#source tr.code ul li {
margin: 0;
padding: 1px 0;
}
table#source tr.code ul li p {
margin: 0;
padding: 0;
}
table#source tr.code td:first-child pre {
padding: 20px;
}
#ribbon {
position: fixed;
top: 0;
right: 0;
}
code .string { color: #219161; }
code .regexp { color: #219161; }
code .keyword { color: #954121; }
code .number { color: #19469D; }
code .comment { color: #bbb; }
code .this { color: #19469D; }</style>
<script>
$(function(){
$('tr.code').hide();
$('tr.filename').toggle(function(){
$(this).nextUntil('.filename').fadeIn();
}, function(){
$(this).nextUntil('.filename').fadeOut();
});
});
</script>
</head>
<body>
<table id="source"><tbody><tr><td><h1>Connect Redis</h1><p>Redis session store for connect backed by <a href="http://github.com/mranney/node_redis">node_redis</a>.</p></td><td></td></tr><tr class="filename"><td><h2 id="lib/connect-redis.js"><a href="#">connect-redis</a></h2></td><td>lib/connect-redis.js</td></tr><tr class="code">
<td class="docs">
<p>Module dependencies.
</p>
</td>
<td class="code">
<pre><code><span class="keyword">var</span> <span class="class">Store</span> = <span class="variable">require</span>(<span class="string">'connect'</span>).<span class="variable">session</span>.<span class="class">Store</span>,
<span class="variable">redis</span> = <span class="variable">require</span>(<span class="string">'./redis'</span>);</code></pre>
</td>
</tr>
<tr class="code">
<td class="docs">
<p>Initialize RedisStore with the given <code>options</code>.</p>
<h2></h2>
<ul><li><p><strong>param</strong>: <em>Object</em> options</p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>
</td>
<td class="code">
<pre><code><span class="keyword">var</span> <span class="class">RedisStore</span> = <span class="variable">module</span>.<span class="variable">exports</span> = <span class="keyword">function</span> <span class="class">RedisStore</span>(<span class="variable">options</span>) {
<span class="variable">options</span> = <span class="variable">options</span> || {};
<span class="class">Store</span>.<span class="variable">call</span>(<span class="this">this</span>, <span class="variable">options</span>);
<span class="this">this</span>.<span class="variable">client</span> = <span class="keyword">new</span> <span class="variable">redis</span>.<span class="variable">createClient</span>(<span class="variable">options</span>.<span class="variable">port</span>, <span class="variable">options</span>.<span class="variable">host</span>, <span class="variable">options</span>);
};</code></pre>
</td>
</tr>
<tr class="code">
<td class="docs">
<p>Inherit from <code>Store</code>.
</p>
</td>
<td class="code">
<pre><code><span class="class">RedisStore</span>.<span class="variable">prototype</span>.<span class="variable">__proto__</span> = <span class="class">Store</span>.<span class="variable">prototype</span>;</code></pre>
</td>
</tr>
<tr class="code">
<td class="docs">
<p>Attempt to fetch session by the given <code>hash</code>.</p>
<h2></h2>
<ul><li><p><strong>param</strong>: <em>String</em> hash</p></li><li><p><strong>param</strong>: <em>Function</em> fn</p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>
</td>
<td class="code">
<pre><code><span class="class">RedisStore</span>.<span class="variable">prototype</span>.<span class="variable">get</span> = <span class="keyword">function</span>(<span class="variable">hash</span>, <span class="variable">fn</span>){
<span class="this">this</span>.<span class="variable">client</span>.<span class="variable">get</span>(<span class="variable">hash</span>, <span class="keyword">function</span>(<span class="variable">err</span>, <span class="variable">data</span>){
<span class="keyword">try</span> {
<span class="variable">fn</span>(<span class="keyword">null</span>, <span class="variable">data</span>
? <span class="class">JSON</span>.<span class="variable">parse</span>(<span class="variable">data</span>.<span class="variable">toString</span>())
: <span class="variable">data</span>);
} <span class="keyword">catch</span> (<span class="variable">err</span>) {
<span class="variable">fn</span>(<span class="variable">err</span>);
}
});
};</code></pre>
</td>
</tr>
<tr class="code">
<td class="docs">
<p>Commit the given <code>sess</code> object associated with the given <code>hash</code>.</p>
<h2></h2>
<ul><li><p><strong>param</strong>: <em>String</em> hash</p></li><li><p><strong>param</strong>: <em>Session</em> sess</p></li><li><p><strong>param</strong>: <em>Function</em> fn</p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>
</td>
<td class="code">
<pre><code><span class="class">RedisStore</span>.<span class="variable">prototype</span>.<span class="variable">set</span> = <span class="keyword">function</span>(<span class="variable">hash</span>, <span class="variable">sess</span>, <span class="variable">fn</span>){
<span class="keyword">var</span> <span class="variable">self</span> = <span class="this">this</span>;
<span class="keyword">try</span> {
<span class="this">this</span>.<span class="variable">client</span>.<span class="variable">set</span>(<span class="variable">hash</span>, <span class="class">JSON</span>.<span class="variable">stringify</span>(<span class="variable">sess</span>), <span class="keyword">function</span>(){
<span class="variable">self</span>.<span class="variable">client</span>.<span class="variable">expire</span>(<span class="variable">hash</span>, <span class="variable">self</span>.<span class="variable">maxAge</span> / <span class="number integer">1000</span> | <span class="number integer">0</span>);
<span class="variable">fn</span> &<span class="variable">amp</span>;&<span class="variable">amp</span>; <span class="variable">fn</span>.<span class="variable">apply</span>(<span class="this">this</span>, <span class="variable">arguments</span>);
});
} <span class="keyword">catch</span> (<span class="variable">err</span>) {
<span class="variable">fn</span> &<span class="variable">amp</span>;&<span class="variable">amp</span>; <span class="variable">fn</span>(<span class="variable">err</span>);
}
};</code></pre>
</td>
</tr>
<tr class="code">
<td class="docs">
<p>Destroy the session associated with the given <code>hash</code>.</p>
<h2></h2>
<ul><li><p><strong>param</strong>: <em>String</em> hash</p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>
</td>
<td class="code">
<pre><code><span class="class">RedisStore</span>.<span class="variable">prototype</span>.<span class="variable">destroy</span> = <span class="keyword">function</span>(<span class="variable">hash</span>, <span class="variable">fn</span>){
<span class="this">this</span>.<span class="variable">client</span>.<span class="variable">del</span>(<span class="variable">hash</span>, <span class="variable">fn</span>);
};</code></pre>
</td>
</tr>
<tr class="code">
<td class="docs">
<p>Fetch number of sessions.</p>
<h2></h2>
<ul><li><p><strong>param</strong>: <em>Function</em> fn</p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>
</td>
<td class="code">
<pre><code><span class="class">RedisStore</span>.<span class="variable">prototype</span>.<span class="variable">length</span> = <span class="keyword">function</span>(<span class="variable">fn</span>){
<span class="this">this</span>.<span class="variable">client</span>.<span class="variable">dbsize</span>(<span class="variable">fn</span>);
};</code></pre>
</td>
</tr>
<tr class="code">
<td class="docs">
<p>Clear all sessions.</p>
<h2></h2>
<ul><li><p><strong>param</strong>: <em>Function</em> fn</p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>
</td>
<td class="code">
<pre><code><span class="class">RedisStore</span>.<span class="variable">prototype</span>.<span class="variable">clear</span> = <span class="keyword">function</span>(<span class="variable">fn</span>){
<span class="this">this</span>.<span class="variable">client</span>.<span class="variable">flushdb</span>(<span class="variable">fn</span>);
};</code></pre>
</td>
</tr> </body>
</html></tbody></table>