Sunday, 4 March 2012

Promocode


Here are some thoughts/ideas cpmes after searched google.com  that I used to create a coupon-like system. This should help to get you started in designing a backend.
1.     You want the (let's call it 'Coupon') to have the ability to be tied to specific items or not, as well as have the ability to be tied to Categories of items (multiple items).
2.     The Coupon should be able to define either a set amount off or a set percentage off either a portion of the sub-total or the entire sub-total.
3.     Tax should be calculated based off of pre-discount sub-total. You can choose to do it the other way, but this is a decision point to consider.
4.     You should be able to specify a start date and end date for the coupon.
5.     You should have the ability to track coupon usage by item and by user. If you have abstract groups of users, then you should be able to track by user group as well.
6.     You should be able to require other items in the coupon which are not discounted in order to get a discount on other items. (Buy This Get That Half Off types of deals)
7.     You should be able to define a minimum number of Items until a coupon can take effect (Buy 3 Tires Get the 4th Free!), as well as a maximum number of times this can be applied (You may not want: Buy 30 Tires Get 10 Tires Free!)
8.     You can decide to restrict certain coupons to a certain user or group of users. You would need to find a way to enforce this restriction if you do.
Just reading this leads me to see at least 3 tables:
Coupons, Item_Coupons, User_Coupons
Where Item_Coupons and User_Coupons map your tables for Items and Users to Coupons. You can also include other tables that may make things easier, such as Coupons_RequiredItems which is another map from Coupons to items that defines the required items for the coupon. The structure of these tables depends heavily on precisely how you intend to implement this.
Of course, if your only intention is to provide X% off an individual Item, then following this would be way too complicated, but much more flexible.

Wednesday, 29 February 2012

PHP APC LOCKING


The full name of this Representational state transfer (REST). it's state less .we can do memory based caching through APC.The APC extension not only does opcode cache (speeds up your php scripts by caching the parsed php script), but it also provides a simple mechanism to store data in shared memory.

Alot of Type of REST Memcached is one of them:-
Memcached is a cache server originally developed by the LiveJournal people and now being used by sites like Digg, Facebook, Slashdot and Wikipedia.


It's working given below :-
Memcached consists of a server and a client part.. The server is a standalone program that runs on your servers and the client is in this case a PHP extension.

If you have 3 webservers which all run Memcached, all webservers connect to all 3 memcached servers. The 3 memcache servers are all in the same 'pool'.

The cache servers all only contain part of the cache. Meaning, the cache is not replicated between the memcached servers.

To find the server where the cache is stored (or should be stored) a so-called hashing algorithm is used. This way the 'right' server is always picked.

Every memcached server has a memory limit. It will never consume more memory than the limit. If the limit is exceeded, older cache is automatically thrown out (if the TTL is exceed or not).

This means it cannot be used as a place to simply store data.. The database does that part. Don't confuse the purpose of the two!

Memcached runs the fastest (like many other applications) on a Linux 2.6 kernel.
By default, memcached is completely open.. Be sure to have a firewall in place to lock out outside ip's, because this can be a huge security risk.