Class: ManqodDB

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/Common/ManqodDB.rb

Overview

this file is part of manqod manqod is distributed under the CDDL licence the author of manqod is Dobai-Pataky Balint([email protected])

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#acacheObject (readonly)

Returns the value of attribute acache.



11
12
13
# File 'lib/Common/ManqodDB.rb', line 11

def acache
  @acache
end

#cacheObject (readonly)

Returns the value of attribute cache.



11
12
13
# File 'lib/Common/ManqodDB.rb', line 11

def cache
  @cache
end

#ccacheObject (readonly)

Returns the value of attribute ccache.



11
12
13
# File 'lib/Common/ManqodDB.rb', line 11

def ccache
  @ccache
end

#connectedObject (readonly)

Returns the value of attribute connected.



11
12
13
# File 'lib/Common/ManqodDB.rb', line 11

def connected
  @connected
end

#manqod_dbObject (readonly)

Returns the value of attribute manqod_db.



11
12
13
# File 'lib/Common/ManqodDB.rb', line 11

def manqod_db
  @manqod_db
end

Instance Method Details

#connect_to_serverObject



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/Common/ManqodDB.rb', line 28

def connect_to_server
	einfo("connecting to #{@manqod_db_uri}","drb")
	@connected=false
	begin
		@manqod_db=DRb::DRbObject.new_with_uri(@manqod_db_uri) unless @manqod_db_uri.nil?
		@connected=@manqod_db.alive?
	rescue =>err
		Eprint.eerror("connecting failed: #{err}\n#{err.backtrace.join("\n")}","drb")
	end
	@connected
end

#set_manqod_db_uri(manqod_db_uri) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/Common/ManqodDB.rb', line 13

def set_manqod_db_uri(manqod_db_uri)
	@manqod_db_uri=manqod_db_uri
	connect_to_server
	begin
		@cache = Memcache.new([@manqod_db.connection['cache_host']],{:prefix_key=>@manqod_db.key_name}) if connected
		@acache = Memcache.new([@manqod_db.admin.connection['cache_host']],{:prefix_key=>@manqod_db.admin.key_name}) if connected
		@ccache = Memcache.new([@manqod_db.client.connection['cache_host']],{:prefix_key=>@manqod_db.client.key_name}) if connected && manqod_db.client
		GtkAttributeStorage.instance.load_all
	rescue => err
		Eprint.eerror("connecting to cache failed: #{err}\n#{err.backtrace.join("\n")}","drb")			
	end

	@connected
end