KVDBphpclassforSAE-PHP source code

Source: Internet
Author: User
KVDBphpclassforSAE

Kvdb php class for SAE
 Kvdb = new SaeKV (); $ this-> kvdb-> init ();} public function get ($ key) {return $ this-> kvdb-> get ($ key);} public function set ($ key, $ value) {return $ this-> kvdb-> set ($ key, $ value) ;}public function replace ($ key, $ value) {return $ this-> kvdb-> replace ($ key, $ value );} public function delete ($ key) {return $ this-> kvdb-> delete ($ key);} public function mget ($ array) {return $ this-> kvdb-> mget ($ array);} public function pkrget ($ Prefix, $ num = 10, $ offset = '') {return $ this-> kvdb-> pkrget ($ prefix, $ num, $ offset);} public function errmsg () {return $ this-> kvdb-> errmsg ();}/*** kvdb cache */public function cache ($ action, $ key, $ value = '', $ timeout = 300) {$ key = 'cache _'. $ key; switch ($ action) {case 'get': return $ this-> cache_get ($ key); break; case 'set ': return $ this-> cache_set ($ key, $ value, $ timeout); break; case 'delete': return $ this-> ca Che_delete ($ key); break; default: return false; break;} public function cache_get ($ key) {$ data = $ this-> get ($ key ); if ($ data) {$ array = unserialize ($ data); if (isset ($ array ['timeout']) & ($ array ['timeout']> time () $ data = $ array ['data']; else $ data = ''; // in the application scenario, the cache will be updated immediately and cannot be deleted .} Return $ data;} public function cache_set ($ key, $ value, $ timeout) {$ array = array ('data' => $ value, 'timeout' => time () + $ timeout); return $ this-> set ($ key, serialize ($ array);} public function cache_delete ($ key) {return $ this-> delete ($ key );}}
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.