Skip to content

Commit

Permalink
fix: rename cache property to database_cache_expiration
Browse files Browse the repository at this point in the history
  • Loading branch information
thibaultcha committed Apr 26, 2015
1 parent 7c67646 commit 81256c8
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 19 deletions.
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
9 changes: 5 additions & 4 deletions kong.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,17 @@ databases_available:
timeout: 1000
keyspace: kong
keepalive: 60000
# Cassandra cache configuration
cache_expiration: 5 # in seconds

# 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: |
worker_processes auto;
error_log logs/error.log info;
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)
9 changes: 5 additions & 4 deletions spec/unit/statics_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,17 @@ databases_available:
timeout: 1000
keyspace: kong
keepalive: 60000
# Cassandra cache configuration
cache_expiration: 5 # in seconds
# 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: |
worker_processes auto;
error_log logs/error.log info;
Expand Down

0 comments on commit 81256c8

Please sign in to comment.