This repository has been archived by the owner. It is now read-only.

New Cache Package #1342

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
10 participants
@LouisLandry
Contributor

LouisLandry commented Jul 3, 2012

This is not ready to be merged, but I wanted to start the conversation about how we dramatically simplify the caching package for Joomla. The existing system is entirely too complex and doesn't honor the principle of separation of concerns. Hopefully this can serve as a starting point for us to figure out what caching looks like for Joomla in the longer term. As with everything these days I'm striving for simple, clear and concise.

@piotr-cz

This comment has been minimized.

Show comment
Hide comment
@piotr-cz

piotr-cz Jul 3, 2012

Contributor

I'm quite happy with JCache shipped with 12.1.

But few things I've been missing:

  • not possible to overwrite some of the cache options (which are set based on CMS settings).
  • I'd like to save in image in cache before start to manipulate it using JImage. Manipulated image should be stored in cache as well until User decides to save it in image format and not JCache format. I ended up doing it without JCache.
Contributor

piotr-cz commented Jul 3, 2012

I'm quite happy with JCache shipped with 12.1.

But few things I've been missing:

  • not possible to overwrite some of the cache options (which are set based on CMS settings).
  • I'd like to save in image in cache before start to manipulate it using JImage. Manipulated image should be stored in cache as well until User decides to save it in image format and not JCache format. I ended up doing it without JCache.
@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Sep 22, 2012

Hm, I'd rather go in the opposite direction and allow for more complex settings such as Stash: https://github.com/tedivm/Stash

I'm also not thrilled with losing the group/pool/bin setting on the cache.... I realize that almost no one uses it though so that's likely just me.

With Stash, instead of having that special runtime property for caching in memory, it adds an "ephermeral" stash handler which keeps it treated by itself.

Moreover, their recent commits include a configurable Multihandler cache storage handler which can be configured to use multiple cache backends intelligently...ie for incredibly large objects[say the JDocument object] the cache can be to Ephemeral + File, really small objects could go to Ephemeral + APC[with it's shared memory model], and everything else can go to Ephemeral + Memcache

The cool factor is on lookups, it will check in all configured storage areas in an optimized order, ie check Ephemeral, then APC, then Memcache - so lookups take a small hit equal to all the failures[variables from Ephemeral.

ghost commented Sep 22, 2012

Hm, I'd rather go in the opposite direction and allow for more complex settings such as Stash: https://github.com/tedivm/Stash

I'm also not thrilled with losing the group/pool/bin setting on the cache.... I realize that almost no one uses it though so that's likely just me.

With Stash, instead of having that special runtime property for caching in memory, it adds an "ephermeral" stash handler which keeps it treated by itself.

Moreover, their recent commits include a configurable Multihandler cache storage handler which can be configured to use multiple cache backends intelligently...ie for incredibly large objects[say the JDocument object] the cache can be to Ephemeral + File, really small objects could go to Ephemeral + APC[with it's shared memory model], and everything else can go to Ephemeral + Memcache

The cool factor is on lookups, it will check in all configured storage areas in an optimized order, ie check Ephemeral, then APC, then Memcache - so lookups take a small hit equal to all the failures[variables from Ephemeral.

@pasamio

This comment has been minimized.

Show comment
Hide comment
@pasamio

pasamio Sep 23, 2012

Contributor

I'd suggest that for someone wanting a more complete cache library with more complicated caching strategies that they could then look into using Stash. Given you point out yourself that almost nobody uses it, it doesn't make sense to maintain a feature that is barely used and is better supported elsewhere in place of providing a simpler and more reliable caching mechanism to meet the majority of use cases.

Contributor

pasamio commented Sep 23, 2012

I'd suggest that for someone wanting a more complete cache library with more complicated caching strategies that they could then look into using Stash. Given you point out yourself that almost nobody uses it, it doesn't make sense to maintain a feature that is barely used and is better supported elsewhere in place of providing a simpler and more reliable caching mechanism to meet the majority of use cases.

@mahagr

This comment has been minimized.

Show comment
Hide comment
@mahagr

mahagr Sep 25, 2012

Contributor

+1 for the simplification -- except that there's really a need to clean up the whole cache. For example in Joomla! 1.5 there was no way to clean up APC cache, which in many cases meant that you had to disable caching and put it back on after few hours to make changes visible. Or you needed to log in the server and do it from command line. Fortunately it's possible in Joomla! 2.5. :)

There's also a need to free up disk space when using file cache, otherwise unused cache entries will slowly fill up the disk.

Contributor

mahagr commented Sep 25, 2012

+1 for the simplification -- except that there's really a need to clean up the whole cache. For example in Joomla! 1.5 there was no way to clean up APC cache, which in many cases meant that you had to disable caching and put it back on after few hours to make changes visible. Or you needed to log in the server and do it from command line. Fortunately it's possible in Joomla! 2.5. :)

There's also a need to free up disk space when using file cache, otherwise unused cache entries will slowly fill up the disk.

@florianv

This comment has been minimized.

Show comment
Hide comment
@florianv

florianv Oct 7, 2012

Contributor

+1 but I think it should be possible to inject a Memcached object in the constructor of JCacheMemcached, allowing a null value and calling _connect() as fallback.

Contributor

florianv commented Oct 7, 2012

+1 but I think it should be possible to inject a Memcached object in the constructor of JCacheMemcached, allowing a null value and calling _connect() as fallback.

@LouisLandry

This comment has been minimized.

Show comment
Hide comment
@LouisLandry

LouisLandry Oct 8, 2012

Contributor

That's an interesting idea @florianv ... I honestly hadn't thought of that.

@mahagr I agree that in general that is a need. I'll take a look at it, but that wasn't really the exercise here. Mostly I am trying to get a feel for how people see the simplification and straightforward approach. I think we've always been too complex in how we deal with cache with all these controllers and handlers and such.

Thanks for the feedback guys!

Contributor

LouisLandry commented Oct 8, 2012

That's an interesting idea @florianv ... I honestly hadn't thought of that.

@mahagr I agree that in general that is a need. I'll take a look at it, but that wasn't really the exercise here. Mostly I am trying to get a feel for how people see the simplification and straightforward approach. I think we've always been too complex in how we deal with cache with all these controllers and handlers and such.

Thanks for the feedback guys!

@florianv

This comment has been minimized.

Show comment
Hide comment
@florianv

florianv Oct 8, 2012

Contributor

@LouisLandry I think about that because in the future we will probably have a dependency injection container holding the JRegistry options and it's likely we will also get drivers from him. So I think there should be a way to inject them via constructor or setter.

Contributor

florianv commented Oct 8, 2012

@LouisLandry I think about that because in the future we will probably have a dependency injection container holding the JRegistry options and it's likely we will also get drivers from him. So I think there should be a way to inject them via constructor or setter.

@pasamio pasamio closed this Oct 17, 2012

@LouisLandry LouisLandry reopened this Oct 17, 2012

@LouisLandry LouisLandry reopened this Oct 17, 2012

@LouisLandry LouisLandry reopened this Oct 17, 2012

@LouisLandry LouisLandry reopened this Oct 17, 2012

@LouisLandry LouisLandry reopened this Oct 17, 2012

/**
- * Constructor
+ * Constructor.

This comment has been minimized.

@elinw

elinw Nov 12, 2012

Contributor

Why?

@elinw

elinw Nov 12, 2012

Contributor

Why?

This comment has been minimized.

@LouisLandry

LouisLandry Nov 12, 2012

Contributor

Why ask why?

@LouisLandry

LouisLandry Nov 12, 2012

Contributor

Why ask why?

This comment has been minimized.

@elinw

elinw Nov 28, 2012

Contributor

Because I can.

@elinw

elinw Nov 28, 2012

Contributor

Because I can.

This comment has been minimized.

@LouisLandry

LouisLandry Nov 28, 2012

Contributor

That can be fixed. 😉

@LouisLandry

LouisLandry Nov 28, 2012

Contributor

That can be fixed. 😉

+ * Constructor.
+ *
+ * @param JRegistry $options Caching options object.
+ *

This comment has been minimized.

@elinw

elinw Nov 12, 2012

Contributor

Why? Why all these periods?

@elinw

elinw Nov 12, 2012

Contributor

Why? Why all these periods?

This comment has been minimized.

@LouisLandry

LouisLandry Nov 28, 2012

Contributor

Because they are the Best. Descriptions. Ever.

@LouisLandry

LouisLandry Nov 28, 2012

Contributor

Because they are the Best. Descriptions. Ever.

This comment has been minimized.

@javigomez

javigomez Dec 31, 2012

Contributor

@elinw the period makes the code assistant of the IDE to stop showing more information. When you put a mouse over a function/method, the IDE usually shows the description of this method on a tooltip. If there is no dot/period, the code assistant continues reading showing something like: Constructor @param JRegsitry.... instead of only showing the description of the method: Constructor. I guess Louis did it for that.

@javigomez

javigomez Dec 31, 2012

Contributor

@elinw the period makes the code assistant of the IDE to stop showing more information. When you put a mouse over a function/method, the IDE usually shows the description of this method on a tooltip. If there is no dot/period, the code assistant continues reading showing something like: Constructor @param JRegsitry.... instead of only showing the description of the method: Constructor. I guess Louis did it for that.

@eddieajau

This comment has been minimized.

Show comment
Hide comment
@eddieajau

eddieajau Nov 28, 2012

Contributor

How are you thinking of instantiating the cache objects (or are we not there yet)?

Contributor

eddieajau commented Nov 28, 2012

How are you thinking of instantiating the cache objects (or are we not there yet)?

@LouisLandry

This comment has been minimized.

Show comment
Hide comment
@LouisLandry

LouisLandry Nov 28, 2012

Contributor

I was thinking something like $cache = new JCacheApc;. What do you think?

Contributor

LouisLandry commented Nov 28, 2012

I was thinking something like $cache = new JCacheApc;. What do you think?

@eddieajau

This comment has been minimized.

Show comment
Hide comment
@eddieajau

eddieajau Nov 28, 2012

Contributor

I was just wondering if you wanted to include a getInstance($driver) convenience method. I'm just thinking of the case where the driver type is coming out of a configuration setting.

Contributor

eddieajau commented Nov 28, 2012

I was just wondering if you wanted to include a getInstance($driver) convenience method. I'm just thinking of the case where the driver type is coming out of a configuration setting.

@ianmacl

This comment has been minimized.

Show comment
Hide comment
@ianmacl

ianmacl Nov 29, 2012

Contributor

It would probably have to be getInstance($options) and $options would have to have a 'type' or 'driver' property. I would be okay with that so long as it doesn't try and cache cache objects. That isn't JCache's job.

Contributor

ianmacl commented Nov 29, 2012

It would probably have to be getInstance($options) and $options would have to have a 'type' or 'driver' property. I would be okay with that so long as it doesn't try and cache cache objects. That isn't JCache's job.

@eddieajau

This comment has been minimized.

Show comment
Hide comment
@eddieajau

eddieajau Nov 29, 2012

Contributor

Or we add a factory class...

Contributor

eddieajau commented Nov 29, 2012

Or we add a factory class...

@dongilbert

This comment has been minimized.

Show comment
Hide comment
@dongilbert

dongilbert Dec 6, 2012

Contributor

@ianmacl what other properties would be present in the $options array that would warrant such an implementation, rather than just passing the driver string?

Contributor

dongilbert commented Dec 6, 2012

@ianmacl what other properties would be present in the $options array that would warrant such an implementation, rather than just passing the driver string?

@ianmacl

This comment has been minimized.

Show comment
Hide comment
@ianmacl

ianmacl Dec 25, 2012

Contributor

Sorry Don, didn't see the question before. Different cache drivers would obviously have different options. If you were using memcached, for example, you might have the address or IP of the memcache server(s) or other connection info. For a file cache you might want to have a configuration option for the root path of the cache folder. For a database cache, you might want to be able to inject in a database driver object.

Contributor

ianmacl commented Dec 25, 2012

Sorry Don, didn't see the question before. Different cache drivers would obviously have different options. If you were using memcached, for example, you might have the address or IP of the memcache server(s) or other connection info. For a file cache you might want to have a configuration option for the root path of the cache folder. For a database cache, you might want to be able to inject in a database driver object.

@dongilbert

This comment has been minimized.

Show comment
Hide comment
@dongilbert

dongilbert Dec 25, 2012

Contributor

Makes sense - I didn't think of that before.

Sent from my iPhone

On Dec 24, 2012, at 10:23 PM, ianmacl notifications@github.com wrote:

Sorry Don, didn't see the question before. Different cache drivers would obviously have different options. If you were using memcached, for example, you might have the address or IP of the memcache server(s) or other connection info. For a file cache you might want to have a configuration option for the root path of the cache folder. For a database cache, you might want to be able to inject in a database driver object.


Reply to this email directly or view it on GitHub.

Contributor

dongilbert commented Dec 25, 2012

Makes sense - I didn't think of that before.

Sent from my iPhone

On Dec 24, 2012, at 10:23 PM, ianmacl notifications@github.com wrote:

Sorry Don, didn't see the question before. Different cache drivers would obviously have different options. If you were using memcached, for example, you might have the address or IP of the memcache server(s) or other connection info. For a file cache you might want to have a configuration option for the root path of the cache folder. For a database cache, you might want to be able to inject in a database driver object.


Reply to this email directly or view it on GitHub.

@florianv

This comment has been minimized.

Show comment
Hide comment
@florianv

florianv Jan 10, 2013

Contributor

It's worth looking at https://github.com/fabpot/Pimple . It's a really simple dependency injection container that we could use to replace the factory.

If we want a configuration file to define the dependencies, it becomes suddently more complicated because we need to check for circular references : A needs B, B needs A. The dependencies must be seen as a graph, and each param/service is a node.

Contributor

florianv commented Jan 10, 2013

It's worth looking at https://github.com/fabpot/Pimple . It's a really simple dependency injection container that we could use to replace the factory.

If we want a configuration file to define the dependencies, it becomes suddently more complicated because we need to check for circular references : A needs B, B needs A. The dependencies must be seen as a graph, and each param/service is a node.

@eddieajau

This comment has been minimized.

Show comment
Hide comment
@eddieajau

eddieajau Mar 16, 2013

Contributor

Closing this PR as it is incorporated into the new Joomla Framework.

Contributor

eddieajau commented Mar 16, 2013

Closing this PR as it is incorporated into the new Joomla Framework.

@eddieajau eddieajau closed this Mar 16, 2013

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.