English 中文(简体)
WordPress Data Storage Efficiency
原标题:

I ve been asked to review a WordPress plugin of sorts and try to find ways of making it faster. The premise of this plugin is basically to store a bunch of users and shifts and appointments and whatnot. It involves a five major variables, Start of week, day of week, user, resource, and appointment.

Currently, it s using a horrendous method of storing the information by creating a string that basically does:

var1::var2::var3::var4::var5;;var1::var2....

Every time someone needs to look at the calendar, it goes into that string and explodes it, and traverses through the entire thing.

What would be the best way to organize the data so that I can just say, start of week is this, day of week is this, give me an array with the rest of the variables in their respective/related positions?

最佳回答

I agree that this may not be your bottleneck -- consider some profiling for better data. But, if you are going to store the data as a string, I think serializing your data structure with the built-in functions is a better idea than doing it by hand. Check out serialize(), or json_encode() if the data might be used by non-PHP apps.

问题回答

Hm. The string may look horrendous (many things in Wordpress do :-), but from a performance perspective I hardly think that is the core of the problem. String operations are still quite fast, and at the end of the day, even if you use some sophisticated storage class, your data will be stored in some way like this, unless you are using a database.

I would use a profiler to find out what the bottlenecks are. Maybe they are not in the PHP code, but in the Javascript that is done on top of it?





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签