我正在尝试更改Zend_Auth的会话后端.但无法成功.在我的bootstrap.php;
$oBackend = new Zend_Cache_Backend_Libmemcached(
array(
'servers' => $servers,
'compression' => false
) );
// configure caching frontend strategy
$oFrontend = new Zend_Cache_Core(
array(
'caching' => true,
'automatic_serialization' => true
) );
// build a caching object
$cache = Zend_Cache::factory( $oFrontend, $oBackend );
$saveHandler = new \Application\Auth\Adapter\Memcached();
$saveHandler->setCacher($cache);
\Zend_Session::setSaveHandler($saveHandler);
Run Code Online (Sandbox Code Playgroud)
它成功地保存了值memcache没有问题.我测试一下;
$namespace = new Zend_Session_Namespace();
$namespace->name = "Fatih";
Run Code Online (Sandbox Code Playgroud)
在其他控制器;
$ns = new Zend_Session_Namespace();
var_dump($ns->name);
Run Code Online (Sandbox Code Playgroud)
没关系,但我在memcache中看不到Zend_Auth值.但是如果var_dump($_SESSION)
我能看到它就像;
["Zend_Auth"]=> array(1) { ["storage"]=> object(Application_Security_Auth_Storage)#66 (1) { ["_user":protected]=> object(Application_Security_Auth_User)#84 (4) { ["id":protected]=> object(MongoId)#87 (1) …Run Code Online (Sandbox Code Playgroud) 我在ubuntu上有一个mongodb replicaset ..在副本集中,主机被定义为localhost.你可以看到;
{
"_id" : "myrep",
"version" : 4,
"members" : [
{
"_id" : 0,
"host" : "localhost:27017"
},
{
"_id" : 2,
"host" : "localhost:27018"
},
{
"_id" : 1,
"host" : "localhost:27019",
"priority" : 0
}
]
Run Code Online (Sandbox Code Playgroud)
}
我想用真正的服务器ip更改主机地址.但是当我运行rs.reconfig时,我收到错误:
{
"assertion" : "hosts cannot switch between localhost and hostname",
"assertionCode" : 13645,
"errmsg" : "db assertion failure",
"ok" : 0
Run Code Online (Sandbox Code Playgroud)
}
我怎么解决呢?谢谢.
我正在尝试实现通用通知系统..我有这样的数据结构;
notification_base:id,type,object
notificiation_sub:id,user_id,not_base_id,lastNotifyTime
notification_action:id,user_id,not_base_id,action,creationDate
Run Code Online (Sandbox Code Playgroud)
所以基本情况是,用户通过发布状态或上传照片等创建通知基础项目.(在这种情况下,照片指的是notification_base表中的类型字段,object_id是post_id或photo_id取决于类型)然后用户订阅对于此notification_base项目..(用户3订阅notification_base 5和最后通知时间x)
之后,另一个用户触摸此notification_base项.(例如,评论状态或类似照片)此操作记录在notification_action表中(用户5在12/02/2011上执行'动作').
我想要的是从用户订阅中获取notification_base项,如果最后notifiytime小于通知操作然后将它们与notification_action连接.我可以使用此sql成功;
对于用户ID 3;
select * from notification_action
inner join notification_base on notification_action.not_base_id = notification_base.id
inner join notification_sub on notification_action.not_base_id = notification_sub.not_base_id
where notification_sub.user_id = 3 and notification_sub.lastShowDate < notification_action.creationDate ;
Run Code Online (Sandbox Code Playgroud)
结果几乎就是我想要的,例如
user x对你的对象做了'action',它在时间t有'type'和object_id
但我也想加入object_id取决于类型..所以我实际上可以学习触摸哪个对象..但是你可以看到类型是动态的,如果type = post对象id指的是post表上的post_id,如果type = photo object id在照片桌等上引用photo_id ..
我尝试做这样的事情,但得到一些语法错误;
SELECT *
FROM notification_action
INNER JOIN notification_base
ON notification_action.not_base_id = notification_base.id
INNER JOIN notification_sub
ON notification_action.not_base_id = notification_sub.not_base_id CASE notification_base.type
WHEN 'photo'
THEN (
INNER JOIN photo
ON photo.id = notification_base.object_id …Run Code Online (Sandbox Code Playgroud) 我正在为case类创建自定义json读取器,但它找不到List [T]的隐式JsonReader类型类,它在其他case类中使用.
当我检查DefaultJsonProtocol时,它已经具有集合的隐式格式;
implicit def listFormat[T :JsonFormat] = new RootJsonFormat[List[T]] {
def write(list: List[T]) = JsArray(list.map(_.toJson).toVector)
def read(value: JsValue): List[T] = value match {
case JsArray(elements) => elements.map(_.convertTo[T])(collection.breakOut)
case x => deserializationError("Expected List as JsArray, but got " + x)
}
}
Run Code Online (Sandbox Code Playgroud)
这是简化的代码;
case class Test(i: Int, d: Double)
case class ListOfTest(t: List[Test])
trait TestResultFormat extends DefaultJsonProtocol {
import CustomFormat._
implicit object TestJsonFormat extends RootJsonReader[Test] {
override def read(json: JsValue): Test = {
val jsObject = json.asJsObject
val jsFields = …Run Code Online (Sandbox Code Playgroud) 我正在尝试学习scala和play框架.我选择了IntelliJ Idea作为ide.问题是编辑器会对进口产生警告; "未使用的进口报表"
import play.api._
import play.api.mvc._
Run Code Online (Sandbox Code Playgroud)
还要对像这样的句子发出警告; "无法解析符号控制器"
object Login extends Controller
Run Code Online (Sandbox Code Playgroud)
我该如何删除警告?
我遵循的步骤;
使用play命令创建模板构思项目;
将scala编译器和库添加到外部库中.
IntelliJ Idea版本:12.1社区Editon
我正在尝试验证浮点数的输入,其中最大值是1.0,最小值是0.
Min : 0
Max : 1
Run Code Online (Sandbox Code Playgroud)
可能的值;
0.1
0.99
0.365
Run Code Online (Sandbox Code Playgroud)
我如何用正则表达式成功呢?
我有java包有Host类和Client类可以反映许多主机
public final class Host {
public final String name;
public final int port;
}
public class SomeClient{...
public Client(Host... hosts) throws Exception {
....
}
Run Code Online (Sandbox Code Playgroud)
我正在编写scala代码来创建这个客户端
// the hosts example is hosts1,host2,host3
def getClient(hosts:String) :SomeClient ={
val default_port:Int = 100
val hostsArr: Array[String] =hosts.split(",")
new Client (hostArr ???)
}
Run Code Online (Sandbox Code Playgroud)
如何将scala数组字符串映射并转换为Host [],以便正确创建客户端?
如何在锚点元素中获得内部跨度,类似于:
<a href="#" class="joinCount">
<span class="data">3<span>
<span class="text">Join</span>
</a>
Run Code Online (Sandbox Code Playgroud)
我想获得价值3并增加价值.
我有一个播放应用程序,我正积极致力于开发环境.不知怎的,它开始给我一个错误;
ProvisionException: Unable to provision, see the following errors:
1) Error in custom provider, org.jboss.netty.channel.ChannelException: Failed to bind to: /127.0.0.1:2552
while locating play.api.libs.concurrent.ActorSystemProvider
while locating akka.actor.ActorSystem
for parameter 6 at play.api.DefaultApplication.<init>(Application.scala:240)
at play.api.DefaultApplication.class(Application.scala:240)
while locating play.api.DefaultApplication
while locating play.api.Application
Run Code Online (Sandbox Code Playgroud)
我验证了端口没有被任何其他应用程序使用,但在控制台上我看到了
Caused by: java.net.BindException: Address already in use
Run Code Online (Sandbox Code Playgroud)
播放版本2.4.3和scala版本2.11.7