Perl keeps track of online orders
Tearing the Drapes
The script needs to peek behind the drapes of the cache to delete the entry after the goods have arrived because you need to know a file's name to be able to delete it from a Git repository; however, the cache generates a 40-byte hash as the filename for each key (as in d549f860476c…). If the user tries to delete the entry for the iPod by issuing a shop got iPod command, the path_to_key function defined in lines 109ff. peeps behind the drapes of the cache abstraction and retrieves the matching pathname. Line 62 then issues a git rm -f command to remove the file both from the local workspace and the entry in the local repository. A subsequent commit makes this permanent.
The shop list command tells the record_list() function, lines 149ff. to call the cache implementation's get_keys() method and return all the keys that exist in the cache as a list. It then passes each element of the list to the get() method, which retrieves the cache entry for a key from disk.
The git commands are all issued through the cmd_run function defined in lines 188ff., which internally calls tap from the Sysadm::Install module, which in turn runs the command lines, intercepts STDERR and STDOUT, and returns them neatly to the caller as return parameters.
The local repository logs all the transactions and therefore could easily reinstate past states. If you are interested in the transactions that have occurred in the repository, you can simply query the repository's log by issuing the git log command in the ~/data/shop directory, as Figure 5 shows.
If two clients independently store the same product in their local repositories, a conflict occurs as soon as the second client attempts to shop push its changes to the centralized server.
Figure 6 shows the nasty error message issued by Git when a second client attempts to shop push. Ideally, when a shop pull follows, git should notice that the changes to the remote branch and the local file are identical, but because the object here is a binary file created by Cache::FileCache, it doesn't trust its own judgment and complains instead. Text files, on the other hand, are handled perfectly by Git in this respect.
If a conflict occurs, Git enters a merge state and waits for the user to resolve it. In this case, you need to delete the product locally (shop got) and then create it again (shop buy). The next push is accepted, and the server repository is happy again.
If the client were to delete the product, not create it again, but issue a push instead, the chainsaw ordered in Figure 6 would disappear from the server repository. After a shop pull on the first client, it would disappear from its local repository, too.
Read full article as PDF:
The Bavarian capital shuns Microsoft, Google, and other alternatives to implement an open-source groupware solution.
Phone vendor partnerships bring Mark Shuttleworth's dream of Ubuntu on a phone a step closer to reality.
Donors will get to vote on new features for the free video editor.
Debian project puts init out to pasture and says no to Ubuntu's Upstart.
Ultra-sophisticated attack tool might have originated from a state-sponsored intelligence service.
New alternative for init comes with a small footprint and minimal configuration.
X marks the target for the next-generation windowing system.
Super-clone CentOS Linux gets beamed up to the mother ship.
HTML technology will enable new video editing and playback options.
New Linux distro is optimzed for gaming.