Class: IronCache::Client

Inherits:
IronCore::Client
  • Object
show all
Defined in:
lib/iron_cache/client.rb

Constant Summary collapse

AWS_US_EAST_HOST =
"cache-aws-us-east-1.iron.io"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/iron_cache/client.rb', line 14

def initialize(options={})
  default_options = {
    :scheme => 'https',
    :host => IronCache::Client::AWS_US_EAST_HOST,
    :port => 443,
    :api_version => 1,
    :user_agent => 'iron_cache_ruby-' + IronCache::VERSION + ' (iron_core_ruby-' + IronCore.version + ')',
    :cache_name => 'default'
  }

  super('iron', 'cache', options, default_options, [:project_id, :token, :api_version, :cache_name])

  IronCore::Logger.error 'IronCache', "Token is not set", IronCore::Error if @token.nil?

  check_id(@project_id, 'project_id')

  @logger = Logger.new(STDOUT)
  @logger.level = Logger::INFO
end

Instance Attribute Details

#loggerObject

Returns the value of attribute logger.



12
13
14
# File 'lib/iron_cache/client.rb', line 12

def logger
  @logger
end

Instance Method Details

#base_urlObject



38
39
40
# File 'lib/iron_cache/client.rb', line 38

def base_url
  super + @api_version.to_s + '/'
end

#cache(name) ⇒ Object



46
47
48
# File 'lib/iron_cache/client.rb', line 46

def cache(name)
  return Cache.new(self, {"name"=>name})
end

#cachesObject



50
51
52
# File 'lib/iron_cache/client.rb', line 50

def caches
  return Caches.new(self)
end

#headersObject



34
35
36
# File 'lib/iron_cache/client.rb', line 34

def headers
  super.merge({'Authorization' => "OAuth #{@token}"})
end

#itemsObject



42
43
44
# File 'lib/iron_cache/client.rb', line 42

def items
  return Items.new(self)
end