### Home Classes Methods

### In Files

- lib/redis_queryable.rb

### Methods

- ::build_key
- ::exists_key?
- ::get
- ::look_up_key
- ::store
- ::switch_to_namespace

### Files

- README_FOR_APP

### Class Index

Quicksearch

- LastFM
- LastFM::Album
- LastFM::Artist
- LastFM::Chart
- LastFM::Request
- LastFM::Track
- LastFM::Validator
- DeviseAuth
- DeviseAuth::RegistrationsController
- DeviseAuth::SessionsController
- Users
- Users::OmniauthCallbacksController
- ApplicationController
- ApplicationHelper
- Artist
- ArtistsController
- ChartsController
- HomeController
- Playlist
- PlaylistsTracks
- RedisQueryable
- SearchController
- Track
- TracksController
- User
- UsersController
- UsersHelper
- YoutubeVideoRating

No matching classes.

# RedisQueryable

### Constants

VALID_NAMESPACES
EXPIRATION

### Public Class Methods

get(namespace, key_hash) click to toggle source

        # File lib/redis_queryable.rb, line 18
    18:   def self.get namespace, key_hash

    19:     key = build_key key_hash.values

    20:     redis = switch_to_namespace namespace

    21:     json = redis.get key

    22:     Hashie::Mash.new(JSON.parse(json))

    23:   end

look_up_key(namespace, key_hash, &block) click to toggle source

        # File lib/redis_queryable.rb, line 25
    25:   def self.look_up_key namespace, key_hash, &block

    26:     if exists_key? namespace, key_hash

    27:       get namespace, key_hash

    28:     else

    29:       block.call

    30:     end

    31:   end

store(namespace, key_hash, value) click to toggle source

        # File lib/redis_queryable.rb, line 10
    10:   def self.store namespace, key_hash, value

    11:     key = build_key key_hash.values

    12:     redis = switch_to_namespace namespace

    13:

    14:     expires = key_hash.has_key?(:type) ? EXPIRATION[namespace][key_hash[:type]] : EXPIRATION[namespace]

    15:     redis.setex key, expires.to_i.days, value

    16:   end

### Private Class Methods

build_key(key_array) click to toggle source

        # File lib/redis_queryable.rb, line 42
    42:   def self.build_key key_array

    43:     key_array.flatten.map do |value|

    44:       value.is_a?(String) ? Digest::SHA1.hexdigest(value) : value.to_s

    45:     end.join(":")

    46:   end

exists_key?(namespace, key_hash) click to toggle source

        # File lib/redis_queryable.rb, line 36
    36:   def self.exists_key? namespace, key_hash

    37:     key = build_key key_hash.values

    38:     redis = switch_to_namespace namespace

    39:     redis.exists key

    40:   end

switch_to_namespace(namespace) click to toggle source

        # File lib/redis_queryable.rb, line 48
    48:   def self.switch_to_namespace namespace

    49:     return Redis::Namespace.new(namespace, :redis => $redis) if VALID_NAMESPACES.include? namespace

    50:     $redis

    51:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.