第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

容量和性能:$ _ COOKIE與$ _SESSION

容量和性能:$ _ COOKIE與$ _SESSION

PHP
ibeautiful 2021-04-09 13:15:01
我有一個非特定于用戶的大型多維數(shù)組?100Mb-150Mb,目前將其保存在一個JSON文件中。必須使用來自API的數(shù)據(jù)每分鐘更新一次此數(shù)組。我不確定應(yīng)該使用$_COOKIE還是$_SESSION存儲它,并避免fopen(); fwrite(); fclose();為了性能而寫文件(即)。可能沒有內(nèi)存問題,因為已經(jīng)使用以下腳本頂部的此設(shè)置收集了數(shù)據(jù):ini_set('max_execution_time', 0);ini_set('memory_limit', '-1');set_time_limit(0);數(shù)據(jù)采集// Config class for path and other constantsrequire_once __DIR__ . "/ConstEQ.php";class EquityRecords extends EQ implements ConstEQ{    public static function getSymbols()    {        //***************** START: ALL SYMBOLS ARRAY ********************** //        // var: is a filename path directory, where there is an md file with list of equities        $list_of_equities_file = __DIR__ . self::SYMBOLS_PATH;        // var: is content of md file with list of equities        $content_of_equities = file_get_contents($list_of_equities_file);        // var is an array(3) of equities such as: string(4) "ZYNE", string(10) "2019-01-04", string(27) "ZYNERBA PHARMACEUTICALS INC"        $symbols_array = preg_split('/\R/', $content_of_equities);        //***************** END: ALL SYMBOLS ARRAY ********************** //        // child and mother arrays are created to help calling equities in batches of 100, which seems to be the API limit.        $child = array();        $mother = array();        // var: is 100 counter        $limit_counter = self::NUMBER_OF_STOCKS_PER_REQUEST;        foreach ($symbols_array as $ticker_arr) {            $limit_counter = $limit_counter - 1;            $symbols_array = preg_split('/\t/', $ticker_arr);            array_push($child, $symbols_array);            if ($limit_counter <= 0) {                $limit_counter = self::NUMBER_OF_STOCKS_PER_REQUEST;                array_push($mother, $child);                $child = array();            }        }        return $mother;    }默認(rèn)情況下,$ _ SESSION的最大容量為128Mb。最大容量$_COOKIE等于$_SESSION嗎?哪種可能使用更快或更應(yīng)該使用,或者還有其他方法可以避免寫入文件來提高性能?
查看完整描述

1 回答

?
MM們

TA貢獻(xiàn)1886條經(jīng)驗 獲得超2個贊

我不確定是否應(yīng)該使用$_COOKIE$_SESSION存儲它…

這些東西很可能都不是。

$_COOKIE映射到用戶瀏覽器中的cookie。每個Cookie的大小上限為4 kB,所有Cookie的大小上限為80 kB。設(shè)置較大的cookie將使對您網(wǎng)站的請求變慢,因此不建議這樣做。

$_SESSION是存儲在Web服務(wù)器上的文件中,并且具有更寬松的大小限制,但每個用戶分別存儲。除非您從此API收集的數(shù)據(jù)是特定于用戶的,否則這也不是一個好選擇。

如果您的數(shù)據(jù)確實是從API收集的并且應(yīng)該在所有用戶之間共享,那么將其存儲在文件中(就像您已經(jīng)在做的一樣?。┦且环N非常合理的方法。Cookie無法容納100 MB,將其存儲在會話中也無濟于事。


查看完整回答
反對 回復(fù) 2021-04-23
  • 1 回答
  • 0 關(guān)注
  • 174 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號