我正在使用@Cacheable注释在缓存中存储一些方法
<cache:annotation-driven />
<bean id="cacheManager" class="org.springframework.cache.support.SimpleCacheManager">
<property name="caches">
<set>
<bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean" p:name="method1" />
<bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean" p:name="method2" />
</set>
</property>
</bean>
Run Code Online (Sandbox Code Playgroud)
但是一旦有多个用户使用该应用程序的缓存已满从而阻止该应用程序。有没有办法限制缓存的大小,如果是的话,这可能会影响应用程序的数据吗?
如何在我的表单中添加文本字段,知道它在我的实体中不存在!!
我在我的树枝上有这个:
<form action="{{ path('add_conge') }}" method="post">
<h1>{{ 'Envoyer une demande de congé'}}</h1>
<div>
{{ form_errors(form.email) }}
{{ form_label(form.email, 'Email Collaborateur:') }}
{{ form_widget(form.email) }}
</div>
<div>
{{ form_errors(form.dateDepart) }}
{{ form_label(form.dateDepart, 'Date depart:') }}
{{ form_widget(form.dateDepart) }}
</div>
//...
Run Code Online (Sandbox Code Playgroud)
我得到这个例外:
Method "email" for object "Symfony\Component\Form\FormView" does not exist in SqliGestionCongeBundle:Default:add.html.twig
Run Code Online (Sandbox Code Playgroud) 嗨,我有这个异常:没有为约束Symfony \ Component \ Validator \ Constraints \ DateTime配置默认选项。
在我的控制器中,我有:
use Symfony\Component\Validator\Constraints\DateTime;
class DefaultController extends Controller
{
public function test2Action()
{
$em = $this->getDoctrine()->getEntityManager();
$id = 1; // ID du bureau de test que l'on a enregistré précédemment
$desk = $this->getDoctrine()->getRepository('MytestBundle:Desk')->find($id);
echo "Le bureau récupéré porte l'ID: ".$desk->getId()." et le titre: ".$desk->getTitle();
$comment = new DeskComment();
$comment->setDescrption("Mon premier commentaire: Joli bureau !");
$comment->setSubmissionIp($this->getRequest()->server->get('REMOTE_ADDR'));
$comment->setCreateAt(new DateTime('now'));
$comment->setDesk($desk); // On lie le commentaire à notre bureau d'ID 1
$em->persist($comment); // …Run Code Online (Sandbox Code Playgroud)