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

Add the cache expiration time to APIObjects. #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Acidity
Copy link

@Acidity Acidity commented Jan 2, 2016

This allows consumers of the library to access the cache expiration time so they can use it as necessary.

@Acidity
Copy link
Author

Acidity commented Jan 2, 2016

Looks like this should solve issue #7.

@jonobrien
Copy link
Contributor

usable?

@wtfrank
Copy link
Contributor

wtfrank commented Jul 25, 2016

I see that you've decided to augment the return value so that its now a tuple containing the original data + the expiry time.

I looked at how evelink (xml api library) deals with returning expiry time, and it returns the timestamp (i.e. the time the item was created) as well as the expiry time.

The second thing that evelink does is it returns a collections.namedtuple rather than tuple. This means that you can do something like X.contracts().result, X.contracts().expires, or X.contracts().timestamp which is quite readable.

That said, doing result, timestamp, expires = X.contracts() as you would with a tuple is still quite readable. Though in the simple case where you don't care about the cache info, you would do result, _, _ = X.contracts() but then that's not so readable.

One problem with using both tuple and namedtuple is that they break existing code. I wonder if there's a way that we can have our cake and eat it, by retaining compatibility with existing code, without making it ugly. Maybe not possible though!

@hkraal
Copy link
Contributor

hkraal commented Jul 26, 2016

Would it really be so hard to keep thing from breaking? I mean X.contracts().result will go through the APIObject.getattr() while X.contracts() goes through APIObject.call() which just as easily could return self().result?

Before we do that we really should get some deprecated notices going for these kind of things

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.

4 participants