Giter VIP home page Giter VIP logo

Comments (14)

marios88 avatar marios88 commented on June 2, 2024 1

@monsefsolutions

If it helps you, this the current way i initialize the files cache ( i am on V8 )

self::$file = \Phpfastcache\CacheManager::getInstance('files',new \Phpfastcache\Drivers\Files\Config([
                'path' => sys_get_temp_dir(),
                'itemDetailedDate' => false,
                'htaccess' => false,
                'securityKey'=> 'YOUR_KEY_HERE',
            ]));

from phpfastcache.

github-actions avatar github-actions commented on June 2, 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 2, 2024

Hello,

Use securityKey for that:

https://github.com/PHPSocialNetwork/phpfastcache/wiki/%5BV4%CB%96%5D-Configuration-Options#file-based-drivers-options-

from phpfastcache.

monsefsolutions avatar monsefsolutions commented on June 2, 2024

First of all, thank you for the quick response, I appreciate that! I have included the securityKey to the ConfigurationOption object. I will wait for the next cron run and let you know if it works. Thanks again.

from phpfastcache.

monsefsolutions avatar monsefsolutions commented on June 2, 2024

I get the following error:

Message: 'Invalid option(s) for the config Phpfastcache\Config\ConfigurationOption: securityKey'

I use version 8.1 of PHP Fast Cache. If I look in lib\Phpfastcache\Config\ConfigurationOption.php I don't see the property securityKey. How to solve?

from phpfastcache.

Geolim4 avatar Geolim4 commented on June 2, 2024

It's because you used the wrong Configuration class (the generic one) x)

Use IOConfigurationOption of Phpfastcache\Drivers\Files\Config instead.

from phpfastcache.

monsefsolutions avatar monsefsolutions commented on June 2, 2024

Thank you again. I only have a trait class IOConfigurationOptionTrait. How to use this i.c.m. with the generic ConfigurationOption class? I want to set the properties: path and securityKey.

from phpfastcache.

monsefsolutions avatar monsefsolutions commented on June 2, 2024

@marios88

Thank you! I will try it and post an update ASAP.

from phpfastcache.

monsefsolutions avatar monsefsolutions commented on June 2, 2024

@marios88

Looks like it works, thank you! However, I now get a permission related error in the cron.log:

Warning: fopen([cache_dir]/Files/11/9d/119d86aff6cd70dcd16a047b72440cb2.txt): failed to open stream: Permission denied in [app_root]/vendor/phpfastcache/phpfastcache/lib/Phpfastcache/Core/Pool/IO/IOHelperTrait.php on line 355

It only seems to go wrong for specific cached files, not for all files. Permissions for the folders are correct from what I can see. Any suggestions or tips how to debug and solve this? I'm struggling because it seems to only occur occassionally.

from phpfastcache.

Geolim4 avatar Geolim4 commented on June 2, 2024

from phpfastcache.

marios88 avatar marios88 commented on June 2, 2024

Yes, probably you run it as a different user from cli than the web server

eg
cron runs as localUser
web is www-data

after you set the correct permissions on your tmp folder,
your cron should look something like this

Replace with your required user
sudo crontab -e -u www-data

SHELL=/bin/bash
0-58/2 * * * * /bin/echo 'CRON: tick' $(whoami) $(date) > /tmp/cron.www-data.tick.log 2>&1
1-59/2 * * * * /bin/echo 'CRON: tock' $(whoami) $(date) > /tmp/cron.www-data.tock.log 2>&1

from phpfastcache.

monsefsolutions avatar monsefsolutions commented on June 2, 2024

Yes, probably you run it as a different user from cli than the web server

eg cron runs as localUser web is www-data

after you set the correct permissions on your tmp folder, your cron should look something like this

Replace with your required user sudo crontab -e -u www-data

SHELL=/bin/bash
0-58/2 * * * * /bin/echo 'CRON: tick' $(whoami) $(date) > /tmp/cron.www-data.tick.log 2>&1
1-59/2 * * * * /bin/echo 'CRON: tock' $(whoami) $(date) > /tmp/cron.www-data.tock.log 2>&1

Thank you, I will try this if I encounter the issue again. As I said, the issue seems to occur occasionally and I don't see it in the latest log.

A last question regarding the www-data crontab: thank you for the clear explanation. Does this solution affect my current crontab setup? Is it possible to run a cron task inside the current crontab (localUser) and switch there to the www-data user? I want to be sure that I'm not changing anything that I can't revert :)

from phpfastcache.

marios88 avatar marios88 commented on June 2, 2024

Personally i avoid switching users in crontab. But in case you want to, and the user has permission and you setup your sudoers correctly try something like this

* * * * * sudo su www-data -s /bin/bash -c 'cd /folder && php index.php' >> /tmp/cron.www-data.log 2>&1

crontab -e -> edit current user's crontab
crontab -e -u XXX -> edit XXX's crontab
Why bother switching users inside crontab?

from phpfastcache.

Geolim4 avatar Geolim4 commented on June 2, 2024

Hello !

I'm closing this issue since the crontab configuration is out of phpfastcache's scope :)

Have a nice day !

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.