Download & Extend

Backport cache to D6

Project:Mongodb
Version:6.x-1.x-dev
Component:Cache
Category:task
Priority:normal
Assigned:Unassigned
Status:needs review

Issue Summary

Patch attached.

Seems to work ok in my limited testing.

AttachmentSizeStatusTest resultOperations
mongo_cache_backport.patch2.37 KBTest request sentNoneView details

Comments

#1

I suggest to remove REQUEST_TIME definition in favor of #1179402: Define REQUEST_TIME for backports. Its also used in many other places.

#2

Category:feature request» task
Status:active» needs review

Attached patch depends on #1179402: Define REQUEST_TIME for backports

AttachmentSizeStatusTest resultOperations
mongodb_cache_1098268.patch1.99 KBTest request sentNoneView details

#3

Cleaner patch

AttachmentSizeStatusTest resultOperations
mongodb_cache_1098268.patch1.99 KBTest request sentNoneView details

#4

Status:needs review» needs work

#5

Status:needs work» needs review

Updated patch: no REQUEST_TIME dependency

AttachmentSizeStatusTest resultOperations
mongodb_cache_1098268_5.patch7.87 KBTest request sentNoneView details

#6

Patch seems not to work for me.

I tried it with a pressflow 6.20 installation.

cd sites/all/modules/mongodb
patch -p1 < patchfile.patch

Created the directory automatically.
Then i was able to activate the module.

Added these to my settings:

$conf['mongodb_connections'] = array(
'mongohost' => array('host' => 'localhost', 'db' => 'mydb'),
);

$conf['mongodb_collections'] = array(
'watchdog' => 'mongohost',
'session' => 'mongohost',
'cache' => 'mongohost',
);

Watchdog messages are written to mydb. Sessions and Cache not.

Any ideas?

#7

In this issue only cache is discussed. Sessions are discussed in different issue.
To use this you need something like this:

$conf['mongodb_connections'] = array('default' => array('host' => 'localhost', 'db' => 'drupal'));
$conf['cache_inc']   = './sites/all/modules/mongodb/mongodb_cache/mongodb_cache.inc';

#8

Alright, that was the point.

Now i get this error:

MongoException: non-utf8 string:

#9

Changed code after line 149 and checked if the data string is valid UTF-8.

if(mb_detect_encoding($entry['data'], 'UTF-8', true)) {
$collection = mongodb_collection($this->bin);
$collection->save($entry);
}

#10

There's an issue here about using mongo binary type for cache.

#11

Thanks.
My changes to use binary storage.....

131,132c131,136
< if ($cache->serialized) {
< $cache->data = unserialize($cache->data);
---
> if($cache->binary && $cache->serialized) {
> $cache->data = unserialize($cache->data->bin);
> } else if(!$cache->binary && $cache->serialized){
> $cache->data = unserialize($cache->data);
> } else {
> $cache->data = $cache->data->bin;
134c138
<
---
>
145a150
> 'binary' => true,
147c152
< 'data' => $scalar ? $data : serialize($data),
---
> 'data' => $scalar ? $data : serialize($data),
149c154
<
---
> $entry['data'] = new MongoBinData($entry['data']);
151d155
<

#12

Updated the patch:

AttachmentSizeStatusTest resultOperations
1098268_mongodb_cache_6.patch8.41 KBTest request sentNoneView details

#13

Fixed patch:

  • Drupal 6 sets HTTP headers in the cache.
AttachmentSizeStatusTest resultOperations
1098268_mongodb_cache_7.patch8.48 KBTest request sentNoneView details

#14

There's no need to validate if the cache data is valid utf. Just use binary type everywhere