-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Update all missing this->_lastKey update for backend cache #12072
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
05c6cf6
Update all missing this->_lastKey update for backend cache
hinablue 3697c8d
Modify the lastKey, this->_lastKey = lastKey is good.
hinablue 81c86ff
Update CHANGELOG
hinablue 9e875b4
Fixed typo in mongo.zep
hinablue d115ea3
Merge remote-tracking branch 'upstream/3.0.x' into 3.0.x
hinablue File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,74 +114,74 @@ class Mongo extends Backend implements BackendInterface | |
throw new Exception("The backend requires a valid MongoDB connection string"); | ||
} | ||
|
||
let mongo = new \MongoClient(server); | ||
} | ||
|
||
/** | ||
* Check if the database name is a string | ||
*/ | ||
let database = options["db"]; | ||
if !database || typeof database != "string" { | ||
throw new Exception("The backend requires a valid MongoDB db"); | ||
} | ||
|
||
/** | ||
* Retrieve the connection name | ||
*/ | ||
let collection = options["collection"]; | ||
if !collection || typeof collection != "string" { | ||
throw new Exception("The backend requires a valid MongoDB collection"); | ||
} | ||
|
||
/** | ||
* Make the connection and get the collection | ||
*/ | ||
let mongoCollection = mongo->selectDb(database)->selectCollection(collection), | ||
this->_collection = mongoCollection; | ||
} | ||
|
||
return mongoCollection; | ||
} | ||
|
||
/** | ||
* Returns a cached content | ||
*/ | ||
public function get(string keyName, int lifetime = null) -> var | null | ||
{ | ||
var frontend, prefixedKey, conditions, document, cachedContent; | ||
|
||
let conditions = []; | ||
let frontend = this->_frontend; | ||
let prefixedKey = this->_prefix . keyName; | ||
let this->_lastKey = prefixedKey; | ||
|
||
let conditions["key"] = prefixedKey; | ||
let conditions["time"] = ["$gt": time()]; | ||
|
||
let document = this->_getCollection()->findOne(conditions); | ||
if typeof document == "array" { | ||
if fetch cachedContent, document["data"] { | ||
if is_numeric(cachedContent) { | ||
return cachedContent; | ||
} | ||
return frontend->afterRetrieve(cachedContent); | ||
} else { | ||
throw new Exception("The cache is corrupt"); | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
/** | ||
* Stores cached content into the file backend and stops the frontend | ||
* | ||
* @param int|string keyName | ||
* @param string content | ||
* @param long lifetime | ||
* @param boolean stopBuffer | ||
*/ | ||
public function save(keyName = null, content = null, lifetime = null, boolean stopBuffer = true) -> boolean | ||
let mongo = new \MongoClient(server); | ||
} | ||
|
||
/** | ||
* Check if the database name is a string | ||
*/ | ||
let database = options["db"]; | ||
if !database || typeof database != "string" { | ||
throw new Exception("The backend requires a valid MongoDB db"); | ||
} | ||
|
||
/** | ||
* Retrieve the connection name | ||
*/ | ||
let collection = options["collection"]; | ||
if !collection || typeof collection != "string" { | ||
throw new Exception("The backend requires a valid MongoDB collection"); | ||
} | ||
|
||
/** | ||
* Make the connection and get the collection | ||
*/ | ||
let mongoCollection = mongo->selectDb(database)->selectCollection(collection), | ||
this->_collection = mongoCollection; | ||
} | ||
|
||
return mongoCollection; | ||
} | ||
|
||
/** | ||
* Returns a cached content | ||
*/ | ||
public function get(string keyName, int lifetime = null) -> var | null | ||
{ | ||
var frontend, prefixedKey, conditions, document, cachedContent; | ||
|
||
let conditions = []; | ||
let frontend = this->_frontend; | ||
let prefixedKey = this->_prefix . keyName; | ||
let this->_lastKey = prefixedKey; | ||
|
||
let conditions["key"] = prefixedKey; | ||
let conditions["time"] = ["$gt": time()]; | ||
|
||
let document = this->_getCollection()->findOne(conditions); | ||
if typeof document == "array" { | ||
if fetch cachedContent, document["data"] { | ||
if is_numeric(cachedContent) { | ||
return cachedContent; | ||
} | ||
return frontend->afterRetrieve(cachedContent); | ||
} else { | ||
throw new Exception("The cache is corrupt"); | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
/** | ||
* Stores cached content into the file backend and stops the frontend | ||
* | ||
* @param int|string keyName | ||
* @param string content | ||
* @param long lifetime | ||
* @param boolean stopBuffer | ||
*/ | ||
public function save(keyName = null, content = null, lifetime = null, boolean stopBuffer = true) -> boolean | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you please return back tabs instead of spaces? |
||
{ | ||
var lastkey, prefix, frontend, cachedContent, tmp, ttl, | ||
collection, timestamp, conditions, document, preparedContent, | ||
|
@@ -195,6 +195,7 @@ class Mongo extends Backend implements BackendInterface | |
} else { | ||
let prefix = this->_prefix; | ||
let lastkey = prefix . keyName; | ||
let this->_lastKey = lastkey; | ||
} | ||
|
||
if !lastkey { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CHANGELOG must be padded on the bottom