Re: sinatra + cassandra

63 views
Skip to first unread message

Jason Rogers

unread,
Aug 8, 2012, 1:29:06 PM8/8/12
to sina...@googlegroups.com
I don't know how you connect to Cassandra, but if you can keep a global connection just create it in a configure block:

configure do
CASSANDRA_DB = ...
end

If you need to establish the connection as your routes are called and disconnect afterward, use before and after blocks:

class CassandraDB
def self. establish_connection!
@connection = ...
end

def disconnect!
...
end

def initialize; ...; end

def some_other_instance_method; ...; end
end

before do
CassandraDB.establish_connection!
end

after do
CassandraDB.disconnect!
end

get '/' do
# use your connection here and throughout your application
'done'
end

--
Jason Rogers


On Tue, Jul 31, 2012 at 2:50 PM, vicent roca daniel <sap...@gmail.com> wrote:
Hi guys,
I'm a little lost trying to get working sinatra with cassandra.  This two technologies are going to be the base of my new app, and I wanna get it right.
¿Do you have any example about how to connect this to guys??

What I can't figure out is where to put the DB code so every file in my APP gets access thi this DB connection.

Huge thanks ;)

--
You received this message because you are subscribed to the Google Groups "sinatrarb" group.
To view this discussion on the web visit https://groups.google.com/d/msg/sinatrarb/-/WqevEpCh69AJ.
To post to this group, send email to sina...@googlegroups.com.
To unsubscribe from this group, send email to sinatrarb+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sinatrarb?hl=en.

Reply all
Reply to author
Forward
0 new messages