Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

readme + rakefile

  • Loading branch information...
commit 586c77c6d6906e97583b6e4468cbbce51069dff0 1 parent 86a18de
@igrigorik authored
Showing with 70 additions and 0 deletions.
  1. +50 −0 README.md
  2. +20 −0 Rakefile
View
50 README.md
@@ -0,0 +1,50 @@
+# RRStat
+
+Implements a round-robin database pattern on top of Redis sorted sets. Ideal for
+answering top/last N queries in (almost) fixed (memory) space. Specify the period
+and precision of each collection bucket, and RRStat will do the rest.
+
+Memory footprint will be limited to number of buckets * number of keys in each. New
+samples will be automatically placed into correct epoch/bucket. Ex:
+
+## Store up to 60s worth of samples, in 10s buckets:
+ rr = RRStat.new(:precision => 10, :buckets => 6)
+ rr.incr("namespace", "key")
+ rr.incr("namespace", "key", 5)
+ rr.score("namespace", "key") => 6
+
+ sleep (10)
+
+ rr.incr("namespace", "key")
+ rr.score("namespace", "key") => 7
+ rr.first("namespace", 1, :with_scores => true) => {"key" => 7}
+
+ sleep(50)
+
+ # epoch will rollover, eliminating first bucket
+ rr.score("namespace", "key") => 1
+
+# License
+
+(The MIT License)
+
+Copyright (c) 2010 Ilya Grigorik
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+'Software'), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
20 Rakefile
@@ -0,0 +1,20 @@
+require "rake"
+
+begin
+ require "jeweler"
+ Jeweler::Tasks.new do |gemspec|
+ gemspec.name = "rrstat"
+ gemspec.summary = "Round robin database via Redis sorted sets"
+ gemspec.description = gemspec.summary
+ gemspec.email = "ilya@igvita.com"
+ gemspec.homepage = "http://github.com/igrigorik/rrstat"
+ gemspec.authors = ["Ilya Grigorik"]
+ gemspec.required_ruby_version = ">= 1.8"
+ gemspec.add_dependency("redis", ">= 2.0.0")
+ gemspec.rubyforge_project = "rrstat"
+ end
+
+ Jeweler::GemcutterTasks.new
+rescue LoadError
+ puts "Jeweler not available: gem install jeweler"
+end
Please sign in to comment.
Something went wrong with that request. Please try again.