[TYPO3-dev] use cache for internal data of a custom extension
Martin Ficzel
martin.ficzel at gmx.de
Sun Mar 5 15:27:37 CET 2006
> We are properly also in the need for a 'private' caching system for
> querys, in my case i also need to do a lot of searching and sorting in
> complete tree's with +200 pages and do that about 8 times. My plugin
> 'knows' when data has been changed and thus I need to refresh upon request.
> So I need to make a USER_INT object and check this and cache the result
> for myself.
why a special query cache, i would prefer a generall caching function
wich stores serialized data and can be used for every kind of data from
every extension.
maybe a small extension wich is providing these functions.
function setCacheData($extKey, $identifierString, $data, $expires) {}
function getCacheData($extKey, $identifierString ) {}
the content could be saved in a single db_table. the extKey could be
saved in a seperate row or could be hashed together with the identifier.
so different extensions cannot get into conflict when using the same
cache table.
i would not care about the kind of cached data and simply store the
serialized value in a blob field and return the unserialized value on
getCacheData.
> New Idea...
> Ideally it would be nice that all USER objects do have on extra
> function, somthing like function hasNewData()
> Which will retrun TRUE or FALSE.
> That means that ALL USER objects need to be initliased (more overhead)
> with maby get/post parameters?!?!?!
> And the plugin is responsible for return TRUE (Yes I have new data) or
> FALSE (NO, use my cached data).
>
> When the plugin returns FALSE then typo3 uses the cached version of the
> last time
> When the plugin return TRUE then simply user_Func (mostly main) will be
> called an the plugin generates new content which will be cached again.
> For migration that means that for USER objects the default return value
> will be TRUE, and for USER_INT objects it will return FALSE.
> In 'some' version of typo3 we can migrate USER_INT back to USER objects
> and have one object type and the plugin can decide?
>
> I don't have anything about this idea but this idea...
> What do you think?
>
> Ries
i think a similar behavior would be quite easy to implement with my
suggested data_cache extension. i would do it like that
1. take the provided data
2. create a hash string for the parameter kombination
3. ask the plugin for cached data
4. if nothing is returned
1. perform the needed query
2. save the result in cache
5. otherwise use the cached value
a bit more code but much more control.
regards Martin
Questions:
- is that a good idea?
- is there really not an existing way to do that? i dont want to invent
the wheel twice.
More information about the TYPO3-dev
mailing list