Permalink
Browse files

Moved limit to a redis server-side sort

  • Loading branch information...
1 parent 5f6abc3 commit 4c737967e95ffb1396e1b371a71283911a5e3926 @whoahbot committed Feb 4, 2010
Showing with 7 additions and 8 deletions.
  1. +1 −1 MIT-LICENSE
  2. +1 −1 benchmark/benchit.rb
  3. +5 −6 lib/dm_redis.rb
View
@@ -1,4 +1,4 @@
-Copyright (c) 2009 Dan Herrera
+Copyright (c) 2010 Dan Herrera
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
View
@@ -2,7 +2,7 @@
require 'dm-core'
require 'benchmark'
require 'redis'
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib/dm_redis_adapter.rb'))
+require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib/dm_redis.rb'))
class Post
include DataMapper::Resource
View
@@ -45,7 +45,6 @@ def read(query)
end
records = query.match_records(records)
- records = query.limit_records(records)
records = query.sort_records(records)
records
end
@@ -141,11 +140,11 @@ def records_for(query)
end
end
- # if query.limit
- # @redis.sort("#{query.model.to_s.downcase}:#{redis_key_for(query.model)}:all", :limit => [query.offset, query.limit]).each do |val|
- # keys << {"#{redis_key_for(query.model)}" => val.to_i}
- # end
- # end
+ if query.limit
+ @redis.sort("#{query.model.to_s.downcase}:#{redis_key_for(query.model)}:all", :limit => [query.offset, query.limit]).each do |val|
+ keys << {"#{redis_key_for(query.model)}" => val.to_i}
+ end
+ end
# Keys are empty, fall back and load all the values for this model
if keys.empty?

0 comments on commit 4c73796

Please sign in to comment.