2009-06-24

【P】memcache : 使用上的一些限制!!

最近在使用memcache存資料的時候,發現怎麼一直沒存起來!

還一直trace Zend framwork的程式,浪費我一堆時間~~

最後才發現是Cache的時間設的太大(也可以說不夠大),

所以就造成了存進Memcache中,馬上就過期~資料就不見了。

後來才想起來,這個問題我之前也遇到過一次~~

結果居然完全忘光光~~真的是笨死了~~

所以這次特別記下來,不要再忘掉了。

 

memcache的一些限制:

  • What is the maxiumum key length? (250 bytes)
    key最大的長度是250 bytes,超過會失敗,如果有加上Prefix的話,會更短
  • What are the limits on setting expire time? (why is there a 30 day limit?)
    Cache的時間最長為30天,也就是2592000秒,超過就會被當成unix timestamp,所以259200"1",就會變成1970-01-31 08:00:01,所以超過這個時間馬上就過期了。
  • What is the maximum data size you can store? (1 megabyte)
    儲存的資料量最大為1MB,太大的話,就要初割~存在不同的key中。

 

節錄原始網頁部份內容:

  • What is the maxiumum key length? (250 bytes)
    The maximum size of a key is 250 characters. Note this value will be less if you are using client "prefixes" or similar features, since the prefix is tacked onto the front of the original key. Shorter keys are generally better since they save memory and use less bandwidth.
  • What are the limits on setting expire time? (why is there a 30 day limit?)
    You can set expire times up to 30 days in the future. After that memcached interprets it as a date, and will expire the item after said date. This is a simple (but obscure) mechanic.
  • What is the maximum data size you can store? (1 megabyte)
    The maximum size of a value you can store in memcached is 1 megabyte. If your data is larger, consider clientside compression or splitting the value up into multiple keys.
  • Why are items limited to 1 megabyte in size?
    Ahh, this is a popular question!
    Short answer: Because of how the memory allocator's algorithm works.
    Long answer: ......略

原文:

FAQ-memcached-Frequently Asked Questions

 

END!!

 

0 comments:

張貼留言