Skip to content
This repository was archived by the owner on Mar 24, 2022. It is now read-only.

Commit cbeb8a9

Browse files
committed
Redis cache (tdiary-cache-redis) support
1 parent 1b05ae6 commit cbeb8a9

File tree

5 files changed

+40
-5
lines changed

5 files changed

+40
-5
lines changed

CHANGELOG.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
## 0.1.1 (2015-09-04)
1+
## 0.1.2 (2015-09-xx)
2+
3+
* Redis cache support (tdiary-cache-redis)
4+
5+
## 0.1.1 (2015-09-10)
26

37
* Update magellan-proxy to 0.0.2.pre
48
* Create database if not exist

README.md

+14-2
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,29 @@ MySQL database connection is configured by environment variables:
2828
* `MYSQL_USERNAME`
2929
* `MYSQL_PASSWORD`
3030

31+
### Cache with redis
32+
33+
magellan-tdiary stores cache into Redis, using tdiary-cache-redis gem.
34+
Redis connection is configured by environment variables:
35+
36+
* `REDIS_HOST`
37+
* `REDIS_PORT` (optional)
38+
* `REDIS_DATABASE` (optional)
39+
* `REDIS_PASSWORD` (optional)
40+
3141
## Local test with docker-compose
3242

3343
You can try tDiary with docker-compose:
3444

3545
```
3646
% docker-compose up -d
37-
Creating magellantdiary_db_1...
38-
Creating magellantdiary_tdiary_1...
47+
magellantdiary_db_1 is up-to-date
48+
magellantdiary_cache_1 is up-to-date
49+
Starting magellantdiary_tdiary_1...
3950
% docker-compose ps
4051
Name Command State Ports
4152
---------------------------------------------------------------------------
53+
magellantdiary_cache_1 /entrypoint.sh redis-server Up 6379/tcp
4254
magellantdiary_db_1 /entrypoint.sh mysqld Up 3306/tcp
4355
magellantdiary_tdiary_1 /opt/magellan-tdiary/entry ... Up
4456
```

build/Gemfile.local

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ gem "mysql2"
44
gem "tdiary", path: "."
55
gem "tdiary-contrib", github: "tdiary/tdiary-contrib"
66
#gem "tdiary-cache-memcached", github: "tdiary/tdiary-cache-memcached"
7-
#gem "tdiary-cache-redis", github: "tdiary/tdiary-cache-redis"
7+
gem "tdiary-cache-redis", github: "tdiary/tdiary-cache-redis"
88
#gem "tdiary-io-mongodb", github: "tdiary/tdiary-io-mongodb"
99
gem "tdiary-io-rdb", github: "tdiary/tdiary-io-rdb"
1010
#gem "tdiary-style-emptdiary", github: "tdiary/tdiary-style-emptdiary"

build/entrypoint

+16
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,21 @@ if ENV['DATABASE_URL']
2222
system('rake -f /opt/magellan-tdiary/Rakefile db:create')
2323
end
2424

25+
if !ENV['REDIS_HOST'] && ENV['CACHE_PORT_6379_TCP_ADDR']
26+
ENV['REDIS_HOST'] = ENV['CACHE_PORT_6379_TCP_ADDR']
27+
end
28+
29+
if !ENV['REDIS_PORT'] && ENV['CACHE_PORT_6379_TCP_PORT']
30+
ENV['REDIS_PORT'] = ENV['CACHE_PORT_6379_TCP_PORT']
31+
end
32+
33+
if !ENV['REDIS_URL'] && ENV['REDIS_HOST']
34+
require 'uri'
35+
ENV['REDIS_URL'] = URI::Generic.build(scheme: "redis", host: ENV['REDIS_HOST'], port: (ENV['REDIS_PORT'] || 6379).to_i).tap{|o|
36+
o.user = ":#{ENV['REDIS_PASSWORD']}" if ENV['REDIS_PASSWORD']
37+
o.path = "/#{ENV['REDIS_DATABASE']}" if ENV['REDIS_DATABASE']
38+
}.to_s
39+
end
40+
2541
program = ARGV.shift
2642
exec(program, *ARGV)

docker-compose.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
tdiary:
2-
image: minimum2scp/magellan-tdiary:0.1.1
2+
image: minimum2scp/magellan-tdiary:0.1.2
33
links:
44
- db
5+
- cache
56
command: bundle exec puma --port 80
67
environment:
78
- MYSQL_USERNAME=tdiary
@@ -21,4 +22,6 @@ db:
2122
#- ./volumes/mysql-data:/var/lib/mysql:rw
2223
- ./volumes/mysql-conf/charset.cnf:/etc/mysql/conf.d/charset.cnf:ro
2324

25+
cache:
26+
image: redis:3.0
2427

0 commit comments

Comments
 (0)