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

Metastore TTL support #117

Merged
merged 6 commits into from
Feb 21, 2016
Merged

Metastore TTL support #117

merged 6 commits into from
Feb 21, 2016

Conversation

mezis
Copy link
Contributor

@mezis mezis commented Aug 27, 2015

This contains #92 and #93, adds travis build configuration, adds missing docs for use_native_ttl, and cleans up the Rakefile.

@rtomayko if you're too busy I'm happy to help maintain this, just let me know.

@grosser
Copy link
Collaborator

grosser commented Jan 27, 2016

can you rebase this so I can merge / see what is new ?

@mezis
Copy link
Contributor Author

mezis commented Jan 28, 2016

@grosser: sure thing. Bear with me as master has diverged a bit ^__^

@mezis
Copy link
Contributor Author

mezis commented Jan 28, 2016

@grosser: rebased now. The CORS fixes (#93) had been merged already so I stripped them from this diff, which is now only about native store TTL support.

@@ -81,7 +81,11 @@ def store(request, response, entity_store)
headers.delete 'Age'

entries.unshift [stored_env, headers]
write key, entries
if request.env['rack-cache.use_native_ttl'] && response.fresh?
Copy link
Collaborator

Choose a reason for hiding this comment

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

would this be better as an option when creating the store ?
this is supposed to be passed in from the outside ... or via another middleware ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

would this be better as an option when creating the store ?

It might, but I was trying to keep this PR about the bug fix — the rack-cache.use_native_ttl env field was already present in other parts of the code (writing to the entity store, just above in this same file).
It just wasn't used properly with metastore writes, and wasn't documented.

I'm happy to make this a store option, but as that would be a breaking change (some users have code that reliad on use_native_ttl), maybe it'd be a better fit in a further PR?

Copy link
Collaborator

Choose a reason for hiding this comment

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

ah, did not know that, sounds good then!

On Tue, Feb 2, 2016 at 12:38 AM, Julien Letessier notifications@github.com
wrote:

In lib/rack/cache/meta_store.rb
#117 (comment):

@@ -81,7 +81,11 @@ def store(request, response, entity_store)
headers.delete 'Age'

   entries.unshift [stored_env, headers]
  •  write key, entries
    
  •  if request.env['rack-cache.use_native_ttl'] && response.fresh?
    

would this be better as an option when creating the store ?

It might, but I was trying to keep this PR about the bug fix — the
rack-cache.use_native_ttl env field was already present in other parts of
the code (writing to the entity store
https://github.com/rtomayko/rack-cache/blob/master/lib/rack/cache/meta_store.rb#L60,
just above in this same file).
It just wasn't used properly with metastore writes, and wasn't documented.

I'm happy to make this a store option, but as that would be a breaking
change (some users have code that reliad on use_native_ttl), maybe it'd
be a better fit in a further PR?


Reply to this email directly or view it on GitHub
https://github.com/rtomayko/rack-cache/pull/117/files#r51538218.

@grosser
Copy link
Collaborator

grosser commented Jan 29, 2016

how about a test that uses rack-cache.use_native_ttl ?


### `use_native_ttl`

Passes on the expiration timestamp to the cache store. This may be necessary
Copy link
Collaborator

Choose a reason for hiding this comment

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

something like that support it, like memcached and redis could be good to not make ppl think heap/file support it ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will fix.

@mezis
Copy link
Contributor Author

mezis commented Feb 19, 2016

@grosser:

how about a test that uses rack-cache.use_native_ttl ?

Done. Not the most elegant but I don't see a better way until we switch the whole thing do injected backend stores (which would be great for testing!)
Let me know if it's good enough for you.

@mezis mezis changed the title Travis builds, Metastore TTL, CORS support Metastore TTL support Feb 19, 2016
@grosser
Copy link
Collaborator

grosser commented Feb 21, 2016

this will blow up custom stores that do not support ttls ... but only if you also have native_ttl enabled ... so hopefully not too bad ... I like that it makes it more consistent with the entity stores that already write with a ttl ...

grosser added a commit that referenced this pull request Feb 21, 2016
@grosser grosser merged commit 0dfbd63 into rtomayko:master Feb 21, 2016
@grosser
Copy link
Collaborator

grosser commented Feb 21, 2016

mocks make the test a bit easier to understand 2d66181

@mezis mezis deleted the fixes branch February 16, 2017 09:28
@mezis mezis restored the fixes branch February 16, 2017 09:28
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.

3 participants