thread-safety

How to disable thread safety in PHP?

柔情痞子 提交于 2020-12-08 07:03:01
问题 I am using some software that requires me to have thread safety disabled. I am working on a Windows server. From what I've read elsewhere, I can't just configure this in the .ini file. Is this true? If so, how would I compile it so that thread safety is turned off? 回答1: You have to compile PHP with ZTS disabled (compile flag --disable-zts ) or download binaries with ZTS disabled. This won't work properly in some webservers, namely those which process several PHP scripts simultaneously in the

How can I lock by cache key?

為{幸葍}努か 提交于 2020-11-26 11:07:27
问题 I am trying to implement a generic thread-safe Cache method, and I wonder how I should implement the lock in it. It should look something like this: //private static readonly lockObject = new Object(); public T GetCache<T>(string key, Func<T> valueFactory...) { // try to pull from cache here lock (lockObject) // I don't want to use static object lock here because then every time a lock is performed, all cached objects in my site have to wait, regarding of the cache key. { // cache was empty

How can I lock by cache key?

☆樱花仙子☆ 提交于 2020-11-26 11:04:06
问题 I am trying to implement a generic thread-safe Cache method, and I wonder how I should implement the lock in it. It should look something like this: //private static readonly lockObject = new Object(); public T GetCache<T>(string key, Func<T> valueFactory...) { // try to pull from cache here lock (lockObject) // I don't want to use static object lock here because then every time a lock is performed, all cached objects in my site have to wait, regarding of the cache key. { // cache was empty

How can I lock by cache key?

随声附和 提交于 2020-11-26 10:58:13
问题 I am trying to implement a generic thread-safe Cache method, and I wonder how I should implement the lock in it. It should look something like this: //private static readonly lockObject = new Object(); public T GetCache<T>(string key, Func<T> valueFactory...) { // try to pull from cache here lock (lockObject) // I don't want to use static object lock here because then every time a lock is performed, all cached objects in my site have to wait, regarding of the cache key. { // cache was empty