diff options
| -rw-r--r-- | environments/development.yml | 6 | ||||
| -rw-r--r-- | lib/StarGit.pm | 10 |
2 files changed, 9 insertions, 7 deletions
diff --git a/environments/development.yml b/environments/development.yml index 28fee7e..f12798b 100644 --- a/environments/development.yml +++ b/environments/development.yml @@ -31,8 +31,6 @@ mongodb: query_timeout: 60000 host: localhost:27017 -plugins: - Redis: - server: '127.0.0.1:6379' - debug: 0 +redis: + server: 'localhost:6379' diff --git a/lib/StarGit.pm b/lib/StarGit.pm index 7931b17..608711b 100644 --- a/lib/StarGit.pm +++ b/lib/StarGit.pm @@ -3,12 +3,16 @@ use Dancer ':syntax'; use StarGit::Graph; use StarGit::Info; -use Dancer::Plugin::Redis; +use Redis; our $VERSION = '0.1'; set serializer => 'JSON'; +my $redis_conf = setting('redis'); +my $redis = Redis->new( server => $redis_conf->{server} ); +$redis->auth( $redis_conf->{auth} ) if $redis_conf->{auth}; + get '/' => sub { template 'index'; }; @@ -24,7 +28,7 @@ get '/api' => sub { get '/graph/local/:name' => sub { my $name = params->{'name'}; - if (my $cached_graph = redis->get($name)){ + if (my $cached_graph = $redis->get($name)){ debug("cache hit for $name"); return $cached_graph; } @@ -39,7 +43,7 @@ get '/graph/local/:name' => sub { $graph->remove_leaves(); my $serialized_graph = to_json(_finalize($graph)); - redis->set($name, $serialized_graph); + $redis->set($name, $serialized_graph); return $serialized_graph; }; |
