[RFC|Rejected] Array based cache

These RFCs were either rejected or have been replaced by an alternative proposal. They will not be included in phpBB.
Post Reply
alexemilov
Registered User
Posts: 5
Joined: Wed Sep 08, 2010 8:38 am

[RFC|Rejected] Array based cache

Post by alexemilov »

Hi, I was looking into the phpBB3.1 new functions and classes and I saw something strange.The way that arrays are saved into the cache.I'm talking about the class loader and the cached_paths.I think that its really better to have selectors for the saving and fetching results from cache.Here is what I mean:

Instead of:

Code: Select all

$my_cache = $this->cache->get('my_cache');
$my_cache['new_variable'] = 1;
$this->cache->put('my_cache', $my_cache);
To use this selector:

Code: Select all

$this->cache->put('my_cache[new_variable]', 1);
I have made those selectors for my forum and I'll post you some example source.

Here are some other types:

$this->cache->put('my_cache[some][array]', 1); // Several arrays
$this->cache->put('my_cache["some"][\'sub\'][arrays], 2); // With " and '
$this->cache->put('my_cache[temp][]', 3); // Each time new row for my_cache[temp], like $array[] = 1;
$this->cache->put('my_cache{the}{other}{type}', 4);

also

$this->cache->get('my_cache[temp]');

Advantages:

Easier, faster and better usage of caching in phpbb.
Usable for caching some temporary content (like anonymous user data, session or etc)

Here is example:
http://phpbb-bulgaria.com/tests/abc.php
http://phpbb-bulgaria.com/tests/abc.php ... custom=abc // Hilit the code

I'll post source soon, I just want to know is it worth to do it. :)

User avatar
callumacrae
Former Team Member
Posts: 1046
Joined: Tue Apr 27, 2010 9:37 am
Location: England
Contact:

Re: [RFC] Array based cache

Post by callumacrae »

I really don't like it :-/
Made by developers, for developers!
My blog

User avatar
DavidIQ
Customisations Team Leader
Customisations Team Leader
Posts: 1905
Joined: Thu Mar 02, 2006 4:29 pm
Location: Earth
Contact:

Re: [RFC] Array based cache

Post by DavidIQ »

How is it "faster"? What are you basing this claim on?
Image

User avatar
naderman
Consultant
Posts: 1727
Joined: Sun Jan 11, 2004 2:11 am
Location: Berlin, Germany
Contact:

Re: [RFC] Array based cache

Post by naderman »

callumacrae wrote:I really don't like it :-/
What was the point of that post? If you have something meaningful to add, please share it. Otherwise please move on to another topic and don't make useless statements like that one.

As for the actual proposal, I'm not sure why this would be better? It also gives the wrong impression that cached values are modified, when in fact they are always entirely overwritten. I don't see why it would be any faster either? What does the implementation look like? Is there a patch / github branch somewhere?

User avatar
callumacrae
Former Team Member
Posts: 1046
Joined: Tue Apr 27, 2010 9:37 am
Location: England
Contact:

Re: [RFC] Array based cache

Post by callumacrae »

naderman wrote:
callumacrae wrote:I really don't like it :-/
What was the point of that post? If you have something meaningful to add, please share it. Otherwise please move on to another topic and don't make useless statements like that one.
Sorry, I should have been clearer. While I'm not a huge fan of the way arrays are changed currently, I think the way he is suggesting is ugly. For example:

Code: Select all

$this->cache->put($array_name . '[' . $key . '][]', 3);
If I looked at that with no knowledge of how it worked, I wouldn't be able to work it out.
Made by developers, for developers!
My blog

User avatar
naim
Registered User
Posts: 50
Joined: Thu Oct 13, 2011 7:21 pm
Location: Isolation
Contact:

Re: [RFC] Array based cache

Post by naim »

It is a good idea, but it has a big disadvantage,
it will put extra load on the processor because you will have to parse the script on every request.

Post Reply