Skip to content

Caching #4

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

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

Caching #4

wants to merge 9 commits into from

Conversation

benserrette
Copy link

Added caching. Caches getCustomer and getPlans. Uses Memcache, APC or Sessions depending on which is available.

@marcguyer
Copy link
Owner

Hi Ben -- Thanks for this. First, I think you should take a look at the way the adapter pattern is used to abstract the http client library used as well as how globals are referenced. I'd like for the cache mechanism to use the adapter pattern. This way, it'd be trivial for someone to write their own adapter if they happen to use something other than the native memcache or APC or whatever. Check these out, for example:

https://github.com/benabus/cheddargetter-client-php/blob/master/Http/AdapterInterface.php

https://github.com/benabus/cheddargetter-client-php/blob/master/Http/NativeAdapter.php

So, a cache interface would have method like load, save, remove, etc. (those are cache-speak for get, set and delete).

Also, I'm afraid I jumped the gun a little. Since you worked on this I've implemented a CG cache on the server side. The client side should leverage this just like a GUI browser would, for example. CG is now honoring the If-Modified-Since and If-None-Match request headers for a few request types. The advantage here is that the client can make the request as usual, receive the cache headers, cache if instructed then subsequent requests receive a 304. It's all a bit complicated. If you'd like to continue working on this, let me know and we can sit down and get into some more detail.

@benserrette
Copy link
Author

I must not understand the adapter pattern as well as I thought. Let me
study up on this a bit more and I'll get back to you.


Ben Serrette
Lead Developer
Code Together LLC
https://squadedit.com
@squadedit

On Tue, Aug 28, 2012 at 11:38 AM, Marc Guyer notifications@github.comwrote:

Hi Ben -- Thanks for this. First, I think you should take a look at the
way the adapter pattern is used to abstract the http client library used as
well as how globals are referenced. I'd like for the cache mechanism to use
the adapter pattern. This way, it'd be trivial for someone to write their
own adapter if they happen to use something other than the native memcache
or APC or whatever. Check these out, for example:

https://github.com/benabus/cheddargetter-client-php/blob/master/Http/AdapterInterface.php

https://github.com/benabus/cheddargetter-client-php/blob/master/Http/NativeAdapter.php

So, a cache interface would have method like load, save, remove, etc.
(those are cache-speak for get, set and delete).

Also, I'm afraid I jumped the gun a little. Since you worked on this I've
implemented a CG cache on the server side. The client side should leverage
this just like a GUI browser would, for example. CG is now honoring the
If-Modified-Since and If-None-Match request headers for a few request
types. The advantage here is that the client can make the request as usual,
receive the cache headers, cache if instructed then subsequent requests
receive a 304. It's all a bit complicated. If you'd like to continue
working on this, let me know and we can sit down and get into some more
detail.


Reply to this email directly or view it on GitHubhttps://github.com//pull/4#issuecomment-8095983.

@benserrette
Copy link
Author

Okay, I've essentially translated it to use more of an adapter pattern, based on the other adapters/interfaces that I saw (Http, Client). I'm hoping this is more of what you were looking for. I haven't added in anything related to your sever-side caching.

Let me know if you think these updates are any better and if you would still like my help. It's been a learning experience for me.

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