problem in clearing Laravel5.7 cache (memcached driver) - laravel

I have upgraded my application laravel version to 5.7 . cache driver is memcached. also i'm using docker compose with separate container for memcached, application, and webserver.
When I try cleaning cache it returns Failed to clear cache. Make sure you have the appropriate permissions.
when I change the cache driver to file it works well. Also, when I'm not running it in docker space it works well!
The problem is probably about flushing memcached. because when i try to clear it manually in my application it returns error 19 which stands for Memcached::RES_SOME_ERRORS! and I dont know what this means exactly!
p.s. and yes, I've created the data folder in storage/framework/cache directory with appropriate permissions.
Any suggestion?

I am assuming you are trying to set up a routine cronjob to clear the cache.
Try running the clear command while you're logged on in a wheel user account
sudo php artisan cache:clear
If it works, you may need to set up that cacheclear on an account with an appropriate access level for memory management tasks.

as I'm using docker i should define hosts as conatiner names.
so I defined MEMCACHED_HOST=memcached in .env file :-"
also i defined application dependency for memcached container.

Related

Laravel Sail how to change local dev domain

I have recently decided to try out Laravel Sail instead of my usual setup with Vagrant/Homestead. Everything seems to be beautifully and easily laid out but I cannot seem to find a workaround for changing domain names in the local environment.
I tried serving the application on say port 89 with the APP_PORT=89 sail up command which works fine using localhost:89 however it seems cumbersome to try and remember what port was which project before starting it up.
I am looking for a way to change the default port so that I don't have to specify what port to serve every time I want to sail up. Then I can use an alias like laravel.test for localhost:89 so I don't have to remember ports anymore I can just type the project names.
I tried changing the etc/hosts file but found out it doesn't actually help with different ports
I essentially am trying to access my project by simply typing 'laravel.test' on the browser for example.
Also open for any other suggestions to achieve this.
Thanks
**Update **
After all this search I actually decided to change my workflow to only have one app running at a time so now I am just using localhost and my CPU and RAM loves it, so if you are here moving from homestead to docker, ask yourself do you really need to run all these apps at the same time. If answer is yes research on, if not just use localhost, there is nothing wrong with it
To change the local name in Sail from the default 'laravel.test' and the port, add the following to your .env file:
APP_SERVICE="yourProject.local" APP_PORT=89
This will take effect when you build (or rebuild using sail build --no-cache) your Sail container.
And to be able to type in 'yourProject.local' in your web browser and have it load your web page, ensure you have your hosts file updated by adding
127.0.0.1 yourProject.localto your hosts file. This file is located:
Windows 10 – “C:\Windows\System32\drivers\etc\hosts”
Linux – “/etc/hosts”
Mac OS X – “/private/etc/hosts”
You'll need to close all browser instances and reopen after making chnages to the hosts file. With this, try entering the alias both with and without the port number to see which works. Since you already set the port via .env you may not need to include it in your alias.
If this doesn't work, change the .env APP_URL=http://yourProject.local:89
Ok another option, in /routes/web.php I assume you have a route set up that may either return a view or call a controller method. You could test to see if you can have this
‘return redirect('http://yourProject.local:89');’ This may involve a little playing around with the routes/controller, but this may be worth looking into.

Symfony first time slow loading

I have been developing a web page named: directorioelectronico.com and I have specially issues now, I will be very grateful that someone can be help me.
The web page is loading very slow in the first loading (5,000ms - 20,000ms) (latest are speeded normally) I tried to install APC module but my host is shared and the administrator can not install it, so I resize realpath_cache_size to 2M and the performance is now better (4,000 - 16,000 ms) somebody knows how I can perform it much more?
In advance, Thank you very much for you help.
My issue was that my share host haven't APC cache and for symfony2 is mandatory have it for have a good load so I change my host provider and now I have a VPS where I can install APC and now it is very fast.
The first time a Symfony program is run with env=prod, it has to create a significant amount of cached code - parsing the routes, annotations, converting configurations files and preparing CSS and Javascript.
It will always be a lot slower the first time, so that the rest of the time it will be fast. If you can run it before the website goes live (eg, with app/console), then that work can happen offline.
After clear:cache the next call on the application will have to rebuild a number cached files. That can be slow - so why make a site visitor trigger it?
If you're clearing the cache in production, try using the cache:warmup command to pre-build the the cache. It will mean the next visitor won't have to wait while the heavy lifting is done.
Something like this should help:
$ php ./app/console clear:cache --env=prod
$ php ./app/console clear:warmup
More info in the Symfony documentation.
I'd also suggest to enable query and result caches for doctrine (did you install/active apc cache for your php installation?). This might further reduce the loading time. Just have a look here :-)
Also try to use a deployment script to automatically trigger the cache clear/warmup, mentioned above. This way you won't forget to call those.
Do you use assetic for css/js? Then combine those files, minify them via assetic filters
Good candidates for deployment scripts are ansible, capifony or just a simple shell script.

FuelPHP Cache visibility between task & app controller

I use memcache as cache driver and I noticed that my app does not see \Cache::set('key', $value); saved in the task. When I try to read it from the app controller level the \Cache::get('key') is not set.
There is no memcache cache driver available in the FuelPHP framework.
If you mean "memcached" (which is not the same), then assuming your config is ok and both the webserver and the commandline use the same config, that should work without problems.

How do I disable Symfony from writing _sess files to my /tmp directory

I am new to symfony and am responsible for a site that I didn't build. For some reason the site is on a live server but running in dev mode. - Im not sure why??
That aside - The website keeps writing _sess files to my /tmp directory. The contents of each _sess file is exactly the same. See below:
_symfony2|a:3:{s:10:"attributes";a:0:{}s:7:"flashes";a:0:{}s:6:"locale";s:2:"en";}
Do I really need all of these files? Can anyone suggest a way of disabling this feature?
Thanks in advance
The default session storage of Symfony2 writes the session information to file(s). The location these files are written to is determined by the config parameter framework.session.save_path. The default value for this is %kernel.cache.dir%/sessions. This means that in a default installation of symfony the session files would be written to the cache directory for the environment.
However, this can be a problem as the cache directory has to be cleared each time an app is deployed, thus logging all the users out. Therefore presumably your app has been configured (most likely in config.yml) to store the session files in /tmp.
As I understand it, sessions that have expired should be garbage-collected at some point. Symfony also has some config params that affect this - see the FrameworkBundle Configuration. I don't know how much traffic your website has but obviously you do need the session files for active sessions. If you think you have a lot of expired sessions you could try tweaking the gc config params.
Alternatively, if having the session files in /tmp is specifically the problem you could relocate them (by changing the value of the framework.session.save_path) or use PDOSessionHandler to store sessions in the database.
I have this problem with symfony 1.4.20 on a web site I inherited.
It is writing files to
/var/lib/php/sessions
every second, until the server runs out of iNodes.
I've tried changing settings in settings.yml. app.yml and PHP session variables.
Nothing sees to be working though, the only way I can stop it is to change the ownership of /var/lib/php/sessions to root and that prevents any session files being created.

How can I clear Magento Cache when using a Memcached server

I've been running on a problem for about two weeks.
I Have a magento which is configured to use a memcache server.
Recently, I got to change the server storing my magento application.
I installed my new server, and just get my magento app up and running on the new server, with one change : I changed the database user and password used to connect to the database server.
I changed from userold to usernew.
This change takes place in my local.xml file.
But now, when I active the magento cache, Magento tries to connect to my database with the old username : userold.
I've tried all things :
rm -fR var/
/etc/init.d/memcache restart
killall memcached
reboot the entire server running memcached!
I still have my cache problem ! I can't get my
Where does this "userold" value is fuc*** stored ?
Any help would really be appreciated ! :)
Hugues.
telnet into the memcache instance and issue a flush_all command. Restarting the memcache server should have already flushed it, but sometimes its worth a try...
Magento uses TwoLevels backend for caching.
Cache stores to both of them.
And according to Zend's code, Magento reads from fast, and then from slow, if nothing returns.
You have to flush memcache and remove /var/cache at the same time.
start a new instance of memcache on a new port eg 11212
now specify this new port in local.xml
that should ensure that it is talking to a new instacne not the old.. or
use htop / top find find the psid of memcache and kill xxxx

Resources