From 7cb63a2c2ee87f97ae2ede0f2be40b4ef98b7236 Mon Sep 17 00:00:00 2001 From: Thibault Charbonnier Date: Sun, 26 Apr 2015 13:14:10 +0200 Subject: [PATCH] rename cache.expiration to `database_cache_expiration` --- kong-0.2.0-1.rockspec | 2 +- kong.yml | 7 +++---- kong/kong.lua | 2 +- kong/plugins/basicauth/access.lua | 2 +- kong/plugins/keyauth/access.lua | 2 +- kong/resolver/access.lua | 2 +- kong/tools/{cache.lua => database_cache.lua} | 4 ++-- kong/tools/io.lua | 3 +++ .../proxy/{cache_spec.lua => database_cache_spec.lua} | 2 +- spec/unit/{cache_spec.lua => database_cache_spec.lua} | 6 +++--- spec/unit/statics_spec.lua | 7 +++---- 11 files changed, 20 insertions(+), 19 deletions(-) rename kong/tools/{cache.lua => database_cache.lua} (94%) rename spec/integration/proxy/{cache_spec.lua => database_cache_spec.lua} (98%) rename spec/unit/{cache_spec.lua => database_cache_spec.lua} (89%) diff --git a/kong-0.2.0-1.rockspec b/kong-0.2.0-1.rockspec index 5c25fe3a84e..bbd26ad21a5 100644 --- a/kong-0.2.0-1.rockspec +++ b/kong-0.2.0-1.rockspec @@ -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", diff --git a/kong.yml b/kong.yml index e055ffd2598..6ac97851e99 100644 --- a/kong.yml +++ b/kong.yml @@ -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; diff --git a/kong/kong.lua b/kong/kong.lua index eded0c806dd..cce2100e20b 100644 --- a/kong/kong.lua +++ b/kong/kong.lua @@ -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" diff --git a/kong/plugins/basicauth/access.lua b/kong/plugins/basicauth/access.lua index ffe192a5c97..2014e8d5cea 100644 --- a/kong/plugins/basicauth/access.lua +++ b/kong/plugins/basicauth/access.lua @@ -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 = {} diff --git a/kong/plugins/keyauth/access.lua b/kong/plugins/keyauth/access.lua index 68340a9571e..980048179a8 100644 --- a/kong/plugins/keyauth/access.lua +++ b/kong/plugins/keyauth/access.lua @@ -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" diff --git a/kong/resolver/access.lua b/kong/resolver/access.lua index e4ee944405d..15e325c3c93 100644 --- a/kong/resolver/access.lua +++ b/kong/resolver/access.lua @@ -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 = {} diff --git a/kong/tools/cache.lua b/kong/tools/database_cache.lua similarity index 94% rename from kong/tools/cache.lua rename to kong/tools/database_cache.lua index b458272b1d5..719adf68b48 100644 --- a/kong/tools/cache.lua +++ b/kong/tools/database_cache.lua @@ -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 @@ -70,4 +70,4 @@ function _M.get_and_set(key, cb) return val end -return _M \ No newline at end of file +return _M diff --git a/kong/tools/io.lua b/kong/tools/io.lua index 14e4cc83566..f5bf22acaaf 100644 --- a/kong/tools/io.lua +++ b/kong/tools/io.lua @@ -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) diff --git a/spec/integration/proxy/cache_spec.lua b/spec/integration/proxy/database_cache_spec.lua similarity index 98% rename from spec/integration/proxy/cache_spec.lua rename to spec/integration/proxy/database_cache_spec.lua index dd12b1b3913..c22b354a13f 100644 --- a/spec/integration/proxy/cache_spec.lua +++ b/spec/integration/proxy/database_cache_spec.lua @@ -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() diff --git a/spec/unit/cache_spec.lua b/spec/unit/database_cache_spec.lua similarity index 89% rename from spec/unit/cache_spec.lua rename to spec/unit/database_cache_spec.lua index b82bc9b80d4..fadf579b308 100644 --- a/spec/unit/cache_spec.lua +++ b/spec/unit/database_cache_spec.lua @@ -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")) @@ -19,4 +19,4 @@ describe("Cache", function() assert.are.equal("basicauth_credentials/username", cache.basicauth_credential_key("username")) end) -end) \ No newline at end of file +end) diff --git a/spec/unit/statics_spec.lua b/spec/unit/statics_spec.lua index f84b21abbbf..6d6e10f655c 100644 --- a/spec/unit/statics_spec.lua +++ b/spec/unit/statics_spec.lua @@ -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;