Skip to content

Instantly share code, notes, and snippets.

@saadullahsaeed
Created August 13, 2012 17:43
Show Gist options
  • Save saadullahsaeed/3342710 to your computer and use it in GitHub Desktop.
Save saadullahsaeed/3342710 to your computer and use it in GitHub Desktop.
Testing 'setbit' and 'bitcount' on Redis 2.6
express = require 'express'
redis = require 'redis'
app = express()
requestCount = 0
client = null
#Going to use Date as the Key
getKey= ->
d = new Date()
"#{d.getFullYear()}-#{d.getMonth()}-#{d.getDate()}"
logView= ->
key = getKey()
console.log "Logging view for #{key}"
client.setbit key, requestCount, 1
requestCount++
initRedis= ->
client = redis.createClient()
client. on "error", (err)=> console.log "Error: #{err}"
app.get '/', (req, res)=>
res.send '1'
logView()
initRedis()
app.listen 3000
console.log "Listening Now "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment