Sha256: ddc3a30b0a427aad479e7f55dfe6863672f59b880eb20409d6a16edec869ecd3

Contents?: true

Size: 523 Bytes

Versions: 6

Compression:

Stored size: 523 Bytes

Contents

module Lunar
  # @private Provides convenience methods to look up keys.
  # Since the Redis KEYS command is actually pretty slow,
  # i'm considering an alternative approach of manually maintaining
  # the sets to manage all the groups of keys.
  class LunarNest < Nest
    def keys
      redis.keys self
    end

    def matches
      regex = Regexp.new(self.gsub('*', '(.*)'))
      keys.map { |key|
        match = key.match(regex)
        [LunarNest.new(key, redis), *match[1, match.size - 1]]
      }
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
lunar-0.5.5 lib/lunar/lunar_nest.rb
lunar-0.5.4 lib/lunar/lunar_nest.rb
lunar-0.5.3 lib/lunar/lunar_nest.rb
lunar-0.5.2 lib/lunar/lunar_nest.rb
lunar-0.5.1 lib/lunar/lunar_nest.rb
lunar-0.5.0 lib/lunar/lunar_nest.rb