Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
256 lines (233 sloc) 7.29 KB
<html>
<head>
<title>merlin</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>merlin</h1><p>object-oriented MVC framework for node.js</p></td><td></td></tr><tr class="filename"><td><h2 id="classes/other/cacheClient.js"><a href="#">cacheClient</a></h2></td><td>classes/other/cacheClient.js</td></tr><tr class="code">
<td class="docs">
<p>function cacheClient() { this.fullConstruct() }</p>
<p> cacheClient.parents = ['merlinObject']</p>
<p> cacheClient.construct = function() {
var myself = this
with ({myself: myself, x: 0}) {</p>
</td>
<td class="code">
<pre><code> <span class="variable">myself</span>.<span class="variable">merlin</span>().<span class="variable">switchboard</span>.<span class="variable">on</span>(<span class="string">'clearAllCaches'</span>, <span class="keyword">function</span>() {
<span class="variable">myself</span>.<span class="variable">clearAllCaches</span>()
})
<span class="variable">myself</span>.<span class="variable">merlin</span>().<span class="variable">switchboard</span>.<span class="variable">on</span>(<span class="string">'clearCacheType'</span>, <span class="keyword">function</span>(<span class="variable">type</span>) {
<span class="variable">myself</span>.<span class="variable">clearCacheType</span>(<span class="variable">type</span>)
})
<span class="variable">myself</span>.<span class="variable">merlin</span>().<span class="variable">switchboard</span>.<span class="variable">on</span>(<span class="string">'clearCache'</span>, <span class="keyword">function</span>(<span class="variable">which</span>) {
<span class="variable">myself</span>.<span class="variable">clearCache</span>(<span class="variable">which</span>)
})</code></pre>
</td>
</tr>
<tr class="code">
<td class="docs">
<p>}
return this
}
cacheClient.bootstrap = function() { return this }</p>
<p> cacheClient.methods = {
getCache: function(key, callback) {
cacheClient.redisClient = cacheClient.redisClient || require('redis').createClient()
cacheClient.redisClient.hgetall('merlin:cacheClient', function(err, redisCache) {
if (typeof redisCache[key] == 'undefined' &amp;&amp; !err)
err = 'cache not found'</p>
<pre><code> if (!err) {
var cacheResponse = {
data: redisCache[key],
save: function() {
if (typeof this.data == 'string' || this.data instanceof String)
theData = this.data
else
theData = JSON.stringify(this.data)
cacheClient.redisClient.hset('merlin:cacheClient', key, theData)
}
}
}
callback(err, cacheResponse)
})
},
ensureCache: function(key, setCallback, retrievedCallback) {
cacheClient.redisClient = cacheClient.redisClient || require('redis').createClient()
var outerArgs = arguments
cacheClient.redisClient.hgetall('merlin:cacheClient', function(err, cache) {
if (err) {
retrievedCallback(err)
return
}
if (typeof cache[key] == 'undefined') {
var saveCache = function(err, updatedCache) {
if (!err) {
if (typeof updatedCache == 'object')
updatedCache = JSON.stringify(updatedCache)
cacheClient.redisClient.hset('merlin:cacheClient', key, updatedCache)
}
retrievedCallback(err, updatedCache)
}
var args = Array.prototype.slice.apply(outerArgs).slice(3)
args.unshift(saveCache)
setCallback.apply(this, args)
}
else {
retrievedCallback(null, cache[key])
}
})
},
clearAllCaches: function() {
cacheClient.redisClient = cacheClient.redisClient || require('redis').createClient()
cacheClient.redisClient.del('merlin:cacheClient')
},
clearCacheByType: function(type) {
// to be handled by subclasses
},
clearCacheByKey: function(key) {
cacheClient.redisClient = cacheClient.redisClient || require('redis').createClient()
cacheClient.redisClient.hdel('merlin:cacheClient', key)
}</code></pre>
<p> }</p>
<p>module.exports = cacheClient</p>
</td>
<td class="code">
</td>
</tr><tr class="filename"><td><h2 id="classes/other/merlinObject.js"><a href="#">merlinObject</a></h2></td><td>classes/other/merlinObject.js</td></tr><tr class="code">
<td class="docs">
<p>function merlinObject() { this.fullConstruct() }</p>
<p> merlinObject.parents = []</p>
<p> merlinObject.bootstrap = function() { return this }
merlinObject.construct = function() { return this }</p>
<p> merlinObject.methods = {
superConstruct: function() {
for (k in this.parentInitializers) {
this.parentInitializers[k].call(this)
}
return this
},</p>
<pre><code>fullConstruct: function() {
this.superConstruct()
this.constructor.construct.apply(this, arguments)
return this
}</code></pre>
</td>
<td class="code">
<pre><code><span class="variable">merlin</span>: <span class="keyword">function</span>() {
<span class="keyword">return</span> <span class="this">this</span>.<span class="variable">constructor</span>.<span class="variable">merlin</span>
}</code></pre>
</td>
</tr>
<tr class="code">
<td class="docs">
<p>}</p>
<p>module.exports = merlinObject</p>
</td>
<td class="code">
</td>
</tr> </body>
</html></tbody></table>
Something went wrong with that request. Please try again.