This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var query = ((MongoQueryable<TEntity>)this.collection.AsQueryable<TEntity>().Where(predicate)).GetMongoQuery(); | |
var memberInitExpression = updateExpression.Body as MemberInitExpression; | |
foreach (MemberBinding binding in memberInitExpression.Bindings) | |
{ | |
string propertyName = binding.Member.Name; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void Inc(Expression<Func<T, bool>> predicate, Expression<Func<T, T>> updateExpression) | |
{ | |
var propertyNamesAndValues = new Dictionary<string, int>(); | |
var query = ((MongoQueryable<T>)this.collection.AsQueryable<T>().Where(predicate)).GetMongoQuery(); | |
var memberInitExpression = (MemberInitExpression)updateExpression.Body; | |
if (memberInitExpression == null) | |
throw new ArgumentException("The update expression must be of type MemberInitExpression.", "updateExpression"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public IEnumerable<T> MapReduce(Expression<Func<T, bool>> predicate,string mapString,string reduceString) | |
{ | |
var query = ((MongoQueryable<T>)this.collection.AsQueryable<T>().Where(predicate)).GetMongoQuery(); | |
var mrResult = this.collection.MapReduce(query, new BsonJavaScript(mapString), new BsonJavaScript(reduceString)); | |
return mrResult.GetInlineResultsAs<T>(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Map() { | |
emit( | |
{ClientVersion:this.ClientVersion, PublisherId:this.PublisherId}, // how to group | |
{SessionCount: 1, userIds:[this.UserId]} // associated data point (document) | |
); | |
} | |
function Reduce(key, values) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EVAL "return redis.call('del', unpack(redis.call('keys', ARGV[1])))" 0 prefix:* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//create config database | |
E:\MongoDB\bin\mongod.exe -dbpath "E:\MongoDB\dbs\config" -port 20000 -logpath "E:\MongoDB\logs\config" --serviceName "MongoDBConfig" --serviceDisplayName "MongoDBConfig" --configsvr --install | |
//create shard1 database | |
E:\MongoDB\bin\mongod.exe -dbpath "E:\MongoDB\dbs\shard1" -port 27018 -logpath "E:\MongoDB\logs\shard1" --serviceName "MongoDBShard1" --serviceDisplayName "MongoDBShard1" --shardsvr --install | |
//create shard2 database | |
E:\MongoDB\bin\mongod.exe -dbpath "E:\MongoDB\dbs\shard2" -port 27019 -logpath "E:\MongoDB\logs\shard2" --serviceName "MongoDBShard2" --serviceDisplayName "MongoDBShard2" --shardsvr --install | |
//create mongos | |
E:\MongoDB\bin\mongos.exe -port 30000 -configdb localhost:20000 -logpath "E:\MongoDB\logs\mongos" -serviceName "MongoDBRouter" --install | |
//start service | |
net start MongoDBConfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mongod --shardsvr --replSet shard-a --dbpath F:\MongoDB\db\rs-a-1 --port 30000 --logpath F:\MongoDB\log\rs-a-1.log --nojournal --install --serviceName MongoDB-rs-a-1 -serviceDisplayName MongoDB-rs-a-1 | |
mongod --shardsvr --replSet shard-a --dbpath F:\MongoDB\db\rs-a-2 --port 30001 --logpath F:\MongoDB\log\rs-a-2.log --nojournal --install --serviceName MongoDB-rs-a-2 -serviceDisplayName MongoDB-rs-a-2 | |
mongod --shardsvr --replSet shard-a --dbpath F:\MongoDB\db\rs-a-3 --port 30002 --logpath F:\MongoDB\log\rs-a-3.log --nojournal --install --serviceName MongoDB-rs-a-3 -serviceDisplayName MongoDB-rs-a-3 | |
mongod --shardsvr --replSet shard-b --dbpath F:\MongoDB\db\rs-b-1 --port 30100 --logpath F:\MongoDB\log\rs-b-1.log --nojournal --install --serviceName MongoDB-rs-b-1 -serviceDisplayName MongoDB-rs-b-1 | |
mongod --shardsvr --replSet shard-b --dbpath F:\MongoDB\db\rs-b-2 --port 30101 --logpath F:\MongoDB\log\rs-b-2.log --nojournal --install --serviceName MongoDB-rs-b-2 -serviceDisplayName MongoDB-rs-b-2 | |
mongod --shardsvr - |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//download openssl source from http://www.openssl.org/source/ | |
//extract it to Desktop(or somewhere else) | |
cd openssl-1.0.1e | |
mkdir openssl_armv7 | |
make clean | |
./configure BSD-generic32 --openssldir=/Users/<username>/Desktop/openssl-1.0.1e/openssl_armv7 | |
//edit makefile | |
//change CC=gcc to CC= /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc | |
//add argument -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk for CFLAG | |
make |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongodb = require('mongodb') | |
, consoleLog = console.log; | |
function mongodbAppender(config) { | |
var host = config.host || 'localhost' | |
, port = config.port || 27017 | |
, server = new mongodb.Server(host, port, {}) | |
, db = new mongodb.Db(config.database, server, { safe: true }) | |
, collection; | |
db.open(function (error, client) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
安装测试服务器,数据盘空间不够,所以需要添加一块。 | |
1、将添加的硬盘安装到机器里; | |
fdisk -l 查看是否有添加的硬盘; | |
如果新加的盘是 /dev/hda | |
2、fdisk /dev/hda 进行分区 | |
n 新建 | |
输入p为创建主分区 | |
p | |
输入1创建第1个主分区 |
OlderNewer