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

Added a clear method that deletes all the values in a session #4

Merged
merged 1 commit into from
Mar 12, 2014
Merged

Conversation

jshrake
Copy link
Contributor

@jshrake jshrake commented Mar 8, 2014

This pull request implements the functionality discussed in issue #3.

@@ -117,6 +119,12 @@ func (s *session) Delete(key interface{}) {
s.written = true
}

func (s *session) Clear() {
for key := range s.Session().Values {
s.Delete(key)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I contemplated repeating the code from the Delete method and then setting s.written = true only once. The current implementation has the advantage of code reuse and that s.written is only updated if Values is non-empty.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this approach for now. I doubt we will be bottlenecking on iteration time here :)

@codegangsta
Copy link
Member

Very cool. I will take a look at this soon

@codegangsta
Copy link
Member

Nice work! Thanks for putting this together

codegangsta added a commit that referenced this pull request Mar 12, 2014
Added a clear method that deletes all the values in a session
@codegangsta codegangsta merged commit 5fadc8e into martini-contrib:master Mar 12, 2014
@jshrake jshrake deleted the clear branch March 12, 2014 14:42
@ghost
Copy link

ghost commented Sep 29, 2015

Nice! Perhaps add it in the example in the readme and close this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants