Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[config] put cache in the DAO config. #162

Merged
merged 1 commit into from
Apr 26, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion kong-0.2.0-1.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ build = {
["kong.tools.syslog"] = "kong/tools/syslog.lua",
["kong.tools.migrations"] = "kong/tools/migrations.lua",
["kong.tools.faker"] = "kong/tools/faker.lua",
["kong.tools.cache"] = "kong/tools/cache.lua",
["kong.tools.database_cache"] = "kong/tools/database_cache.lua",
["kong.tools.timestamp"] = "kong/tools/timestamp.lua",
["kong.tools.printable"] = "kong/tools/printable.lua",
["kong.tools.http_client"] = "kong/tools/http_client.lua",
Expand Down
7 changes: 3 additions & 4 deletions kong.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@ databases_available:
keyspace: kong
keepalive: 60000

# Cassandra cache configuration
database_cache_expiration: 5 # in seconds

# Sends anonymous error reports
send_anonymous_reports: true

nginx_plus_status: false

# Cassandra cache configuration
cache:
expiration: 5 # in seconds

# Nginx configuration
nginx: |
worker_processes auto;
Expand Down
2 changes: 1 addition & 1 deletion kong/kong.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

utils = require "kong.tools.utils"
local IO = require "kong.tools.io"
local cache = require "kong.tools.cache"
local cache = require "kong.tools.database_cache"
local constants = require "kong.constants"
local timestamp = require "kong.tools.timestamp"
local stringy = require "stringy"
Expand Down
2 changes: 1 addition & 1 deletion kong/plugins/basicauth/access.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local constants = require "kong.constants"
local stringy = require "stringy"
local cache = require "kong.tools.cache"
local cache = require "kong.tools.database_cache"

local _M = {}

Expand Down
2 changes: 1 addition & 1 deletion kong/plugins/keyauth/access.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local constants = require "kong.constants"
local Multipart = require "multipart"
local stringy = require "stringy"
local cache = require "kong.tools.cache"
local cache = require "kong.tools.database_cache"

local CONTENT_TYPE = "content-type"
local CONTENT_LENGTH = "content-length"
Expand Down
2 changes: 1 addition & 1 deletion kong/resolver/access.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local stringy = require "stringy"
local url = require("socket.url")
local cache = require "kong.tools.cache"
local cache = require "kong.tools.database_cache"

local _M = {}

Expand Down
4 changes: 2 additions & 2 deletions kong/tools/cache.lua → kong/tools/database_cache.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local _M = {}

function _M.set(key, value, exptime)
if exptime == nil then
exptime = configuration and configuration.cache.expiration or 0
exptime = configuration and configuration.database_cache_expiration or 0
end

local cache = ngx.shared.cache
Expand Down Expand Up @@ -70,4 +70,4 @@ function _M.get_and_set(key, cb)
return val
end

return _M
return _M
3 changes: 3 additions & 0 deletions kong/tools/io.lua
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ function _M.load_configuration_and_dao(configuration_path)
-- Adding computed properties to the configuration
configuration.pid_file = path:join(configuration.nginx_working_dir, constants.CLI.NGINX_PID)

-- Alias the DAO configuration we are using for this instance for easy access
configuration.dao_config = dao_config

-- Instanciate the DAO Factory along with the configuration
local DaoFactory = require("kong.dao."..configuration.database..".factory")
local dao_factory = DaoFactory(dao_config.properties)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ local created_ids = {}
local kWebURL = spec_helper.API_URL
local kProxyURL = spec_helper.PROXY_URL

describe("Cache #proxy", function()
describe("Database cache", function()

setup(function()
spec_helper.prepare_db()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local cache = require "kong.tools.cache"
local cache = require "kong.tools.database_cache"

describe("Cache", function()
describe("Database cache", function()

it("should return a valid API cache key", function()
assert.are.equal("apis/httpbin.org", cache.api_key("httpbin.org"))
Expand All @@ -19,4 +19,4 @@ describe("Cache", function()
assert.are.equal("basicauth_credentials/username", cache.basicauth_credential_key("username"))
end)

end)
end)
7 changes: 3 additions & 4 deletions spec/unit/statics_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,14 @@ databases_available:
keyspace: kong
keepalive: 60000

# Cassandra cache configuration
database_cache_expiration: 5 # in seconds

# Sends anonymous error reports
send_anonymous_reports: true

nginx_plus_status: false

# Cassandra cache configuration
cache:
expiration: 5 # in seconds

# Nginx configuration
nginx: |
worker_processes auto;
Expand Down