Memcached In A shell Using nc And echo
Some example accessing memcached from a shell using nc and echo
Storage Commands
set add get gets replace append prepend cas delete command [key] [flags] [exptime] [bytes] [noreply]\r\n[value]\r
Parameters :
[key] : the key of the data stored [flags] : 32-bit unsigned integer that the server store with the data (provided by the user), and return along the data when the item is retrieved [exptime] : expiration time in seconds, 0 mean no delay, if exptime is superior to 30 day, Memcached will use it as a UNIX timestamps for expiration [bytes] : number of bytes in the data block [cas unique] : unique 64-bit value of an existing entry (retrieved with gets command) to use with cas command [noreply] : optional parameter that inform the server to not send the reply
Memcached And PHP, Caching Mysql Query Result
I’ve been messing around with memcached and php-pecl-memcache to cache sql query result. Many web sites & applications such as Facebook, LiveJournal, Flickr, Slashdot, WikiPedia/MediaWiki, SourceForge, Digg and Twitter use memcached to enhance their performance.
Memcached (Memory Cache Daemon) was developed by the team at LiveJournal to improve performance of their social blogging site by minimizing the impact of the bottleneck caused by reading data directly from the database. Memcached is a server that caches Name Value Pairs in memory. The “Name”, or key, is limited to 250 characters, and the “Value” is limited to 1MB in size. Values can consist of data, HTML Fragments, or binary objects; almost any type of data that can be serialized and fits in memcached can be stored.
here is simple example/demonstration how to cache regular sql query
First of all, we need memcached daemon run on system
$ ps ax | grep memcached 8955 ? Ssl 0:00 memcached -d -p 11211 -u memcached -m 256 -c 1024 -P /var/run/memcached/memcached.pid -l 127.0.0.1
Setup simple mysql database/tables as shown bellow:
mysql-shell> CREATE DATABASE memcache;
Copy/Paste this tables schema to your mysql shell/console
CREATE TABLE memc ( personID int NOT NULL AUTO_INCREMENT, PRIMARY KEY(personID), FirstName varchar(15), LastName varchar(15), Age int ); hit enter/return key
Insert some data
mysql-shell> INSERT INTO memc (FirstName, LastName, Age) VALUES('Memory', 'Cache', '100');
postfix-2.9.20110501 SRC RPM With sqlite3 Support
Since postfix-2.9. 20100617, sqlite3 support feature was added. Now, in postfix-2.9.20110501 rpm source, i’ve included sqlite3 feature after some tweaking on Simon J. Mudd’s postfix source. Adding sqlite3 support howto can be read officially from here:
http://www.postfix.org/SQLITE_README.html
Before getting any further, i must warn you that i’m not test sqlite feature yet, since i don’t use sqlite as sql storage backend. it was compiled againts sqlite library in my system. but not tested.
rpm source can be obtain here:
postfix-2.9.20110501 (34 downloads )Instructions:
After download the source install the source
$ rpm -Uvh postfix-2.9.20110501.src.rpm
Nginx As Reverse Proxy IPV6 to IPV4 Website
nginx mod_strip module and textarea
I was asking to Evan Miller if his nginx mod_strip module can honour <textarea> tag. i got quick responses from him.
previous mod_strip module eliminates newline characters within <textarea> list contents. here’s examples with latest mod_strip. I’ve tested it using postfixadmin.
configuration:
server { listen xxx.xxx.xxx.xxx:80; server_name www.example.com; strip on; access_log /var/log/nginx/www.example.com-access.log main; location / { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://127.0.0.1:80; } }
Nginx Configuration SyntaxHighlighting
Nginx + Vlc Streaming Cheap Webcam
I was experimenting with cheap webcam, vlc on my windows xp workstation. Playing directly using vlc, performance was adequate. but when it came accross network/WAN, delay started increasing between 4-5 seconds(video/audio). i suspect, transcoding are behind these streaming lag. i don’t know what is the best tuning. but here’s the final setting.
start /high vlc.exe --logo-file avatar.png dshow:// :dshow-vdev="VideoCAM Eye" :dshow-adev="SigmaTel Audio" :dshow-caching="0" :sout=#transcode{vcodec=h264{keyint=15,vbv-maxrate=160,vbv-bufsize=160},acodec=mp3,deinterlace,samplerate=44100,sfilter=logo}:std{access=http{mime=video/x-flv},mux=ffmpeg{mux=flv},dst=0.0.0.0:8088/stream.flv,sdp=sap://,name="Webcam 3G"} --ttl 12