Giter VIP home page Giter VIP logo

Comments (9)

Tommuh avatar Tommuh commented on June 10, 2024 1

Thank you for your feedback. Can't agree more on that.

I removed my static config/item functions and added my own config and item classes to stay with the design choices that are made.

from phpfastcache.

github-actions avatar github-actions commented on June 10, 2024

Hello curious contributor !
Since it seems to be your first contribution, make sure that you've been:

  • Reading and searching out our WIKI
  • Reading and agreed with our Code Of Conduct
  • Reading and understood our Coding Guideline
  • Reading our README
    If everything looks unclear to you, tell us what πŸ˜„
    The Phpfastcache Team

from phpfastcache.

Geolim4 avatar Geolim4 commented on June 10, 2024

Hello,

The sub-directory is necessary for security reason, so it won't be removed/.

Its purpose is to avoid hosts/shared website cache collisions.

Cheers,
Georges

from phpfastcache.

Tommuh avatar Tommuh commented on June 10, 2024

The host/shared website collisions is only when the tmp directory is used?

What I mean is. In mine setup each project/website has it's own cache directory already. Having those extra 2 directories seems off when a custom path is set.

I totally understand it when the default tmp directory is used.

from phpfastcache.

Tommuh avatar Tommuh commented on June 10, 2024

I did overwrite the Files driver and changed it the way I needed.
I will leave example behind if anyone else ever need it.

Removed by @Geolim4 for security concerns.

Using it:

CacheManager::addCoreDriverOverride(
	'Files', 
	\Cache\Files::class
);

$cache = new Psr16Adapter('Files', new FilesConfig([
	'path'            => '/some/directory',
	'autoTmpFallback' => false
]);  

What I did notice is that there might be a bug with incorrectly calling "getItemClass". When I set this hard coded to the existing Files\Item class like I did with the config class it keeps searching in the directory were my custom files driver is saved.

I think in CacheItemPoolTrait line 74 and 135 the calling with "self" need to be changed to "static".
self::getItemClass() => static::getItemClass()

from phpfastcache.

Geolim4 avatar Geolim4 commented on June 10, 2024

The host/shared website collisions is only when the tmp directory is used?

What I mean is. In mine setup each project/website has it's own cache directory already. Having those extra 2 directories seems off when a custom path is set.

I totally understand it when the default tmp directory is used.

No, I've already seen collision risks when people are using multiple files driver-based in the same directory: Ex: Sqlite and Files.
If you don't make a sub-directory, some CRUD operations (e.g: clear cache) will impact others drivers.

That's why the sub-directory is necessary.

from phpfastcache.

Geolim4 avatar Geolim4 commented on June 10, 2024

I think in CacheItemPoolTrait line 74 and 135 the calling with "self" need to be changed to "static".
self::getItemClass() => static::getItemClass()

Its not needed as this is a core feature not meant to be overridden. Also static keyword have a performance issue since it is JIT-evaluated while self is lexer-evaluated.

from phpfastcache.

Tommuh avatar Tommuh commented on June 10, 2024

I do understand your concern. I'm ok with my work around because I only use one adapter for one specific job.

Did you notice any performance problems with self/static? Isn't it called once when creating the driver? Just curious..

from phpfastcache.

Geolim4 avatar Geolim4 commented on June 10, 2024

I do understand your concern. I'm ok with my work around because I only use one adapter for one specific job.

Did you notice any performance problems with self/static? Isn't it called once when creating the driver? Just curious..

It is also called here:
lib/Phpfastcache/Core/Pool/CacheItemPoolTrait.php:135
lib/Phpfastcache/Cluster/ClusterPoolAbstract.php:193

So it is called every time you need a cache item. On big project this can have a significant impact.
I'm on philosophy anyway to have any php engine optimizations: isset instead of array_key_exists, fully qualified php core functions, self instead of static where it applies, static closure where it applies, etc.

It's all those micro-optimizations that end to noticeable optimization in the end.

from phpfastcache.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.