Caching with Entity Framework - entity-framework

has anyone some experience with caching and EF ?
I was looking at the EFProviderWrappers http://code.msdn.microsoft.com/EFProviderWrappers but this project seems to be outdated. Does someone used it with success ?
Or are there other better solution ?

If you want to cache LINQ query results I recommend you try the Pete Montgomery solution. It is applicable in ASP.NET but can be used in desktop apllication if replace HttpRuntime.Cache to System.Runtime.Caching.MemoryCache.Default.

You may try to look at second level caching made by Eye Soft. Here's link to Nuget package and its source code on Codeplex. It's based on EFProviderWrappers, but refactored and seems up to date more or less.

Related

Toggling ProxyCreation in EF7 under new configuration

So in EF6, one could disable proxy creation like so:
this.Configuration.ProxyCreationEnabled = false;
From what I could find, the configuration scheme under EF7 has changed, but I cannot find anything on how to do so. I went through https://docs.efproject.net/en/latest/miscellaneous/configuring-dbcontext.html and even analyzed the DbContextOptionsBuilder object, but cannot find anything on it.
Am I going about ti the wrong way or is there something im missing? Thanks in advance.
EF7 EF Core 1.0 does not do proxy creation, so accordingly, there is no configuration option for this. See https://github.com/aspnet/EntityFramework/issues/997
Entity Framework Core 2.1 starts to support Lazy load. Please see: https://learn.microsoft.com/en-us/ef/core/querying/related-data#lazy-loading
Here is recent question with answers from stackoverflow:
What is the equivalent of .Configuration.ProxyCreationEnabled in EF Core?

Generate PDF in Play Framework Scala

I'm using Play framework 2.2.x and I'm looking for some plugin/lib for generating PDF.
I found this plugin:
https://github.com/joergviola/play20-pdf,
but it's for Java and is not supported already
Do u know some repository with this library? Or some alternatives for Scala and Play Framework?
=== Update
I found some fork, but still no working repository
https://github.com/alias1/play2pdf
Try this one https://github.com/Kaliber/scala-pdf. It is really easy to use, and you can define your own css or even use bootstrap.
This seems to be a very good solution : https://github.com/cloudify/sPDF
Otherwise, I highly recommend http://www.html2pdf.it/
Well javascript can be easy solution . You can use jspdf .

How to selectively clear cache (using tags or other option) with Memchached backend and Zend Framework

We use Memcached and Zend Framework in our web project. Now, we need to clean cache selectively using tags as specified in Zend_Cache API.
Unfortunately, memcached doesn't support tags.
I have found these workarounds:
Memcached-tag project. Has anybody tested it? How to implement it with Zend?
Use wildchards like in this question, but it seems a bit confusing, less transparent and harder to implement with Zend.
Use this implementation or this one, for supporting tags in Memcached, beeing aware of the drawbacks.
Any other option?
Thanks in advance
You're right. Memcache don't support tags.
You can use another key-value to implement tag for memcache.
EX :
$this->objCache->save($arrResults, $strKey,array($strMyTag),$intCacheTime) // note : array($strMyTag) don't work for Memcache
MemcacheTag::setTag($strKey, $strMyTag) // our work around
About setTag Method & MemcacheTag:
function setTag($strKey,$strTag){
$arrKey = $cacheOjb->get($strTag);
$arrKey[]= $strKey;
}
function deleteCacheWithTag($strTag){
$arrKey = $cacheOjb->get($strTag);
foreach ($arrKey as $strKey){
$objCache->delete($strKey);
}
}
This work around is quite simple and it works for my projects.
*Note: these codes need some modification, sorry for posting in a hurry

node-mongodb-native example code vs docs code? which to use?

I just wrote my first nodejs program using the node-mongodb-native driver. I used the documentation code from the github page, i.e.:
var mongodb = require("mongodb"),
mongoserver = new mongodb.Server('localhost', 6574),
dbConnector = new mongodb.Db('test', mongoserver);
dbConnector.open(function(err, db){
if(err)
console.log('oh shit! connector.open error!');
else{
...
However, upon looking at some example code on the github page, I discovered that the set up code looks very different from what I used. Does anybody know if there's any real difference between the different methods? I'm completely new to all this stuff and can't really tell if there's any reason to use one over the other. The code I wrote seems to run fine, but if the creator of the driver is using different code, I figured it would be worth checking if there are any reasons for that.
Thanks in advance for any replies!
Sami
Hi I'm the creator and no there is no particular reason you can't use your style. As when it comes to docs I usually tell people to start with the integration tests as there are many examples on how to do stuff. Unfortunately due to having a fulltime job the docs are not kept up to date at the pace I would like to.
I'm hoping to do something with that come late september but right now I'm trying to just get the driver up to the expected features of mongodb including making it work with 1.9.X and higher.
I'll accept any docs pull requests happily as the more the community help me the more it helps itself :)

Zend-Framework 1.x with Doctrine 2.x

I know that there are many examples but this is my problem, because now I don't know which is the best and I don't understand every samples. This before I used doctrine 1.x and that was more simple for me, because there was only few steps to connect to database with doctrine and use it:
1.) Created User.yml file into application/doctrine/schema folder
2.) Run generate-models-yaml in cli which generated php classes into application/models/generated folder
3.) Again in cli run: create-db, create-tables
4.) In IndexController / IndexAction I can use it:
$newUser = new User();
$newUser->name = 'Demo';
$newUser->save;
And that's all. But with 2.0 I have some question:
- Where is the best place for mapping yaml files?
- How can I generate Entities from yaml? (Depending from the first answer)
- How can I create/drop db and tables?
- Which solution is the best EntitiyManager?
So I just want the most simple sample like my doctrine 1.x sample. Thanks!
For me best integration Bisna from Guilherme Blanco https://github.com/guilhermeblanco/ZendFramework1-Doctrine2
Step by step video tutorial using Bisna integration
http://www.zendcasts.com/unit-testing-doctrine-2-entities/2011/02/
Another very good example of ZF1 and Doctrine 2 with fully tested code (PHPUnit & Ant):
https://github.com/eddiejaoude/Zend-Framework--Doctrine-ORM--PHPUnit--Ant--Jenkins-CI--TDD-
They try to work best practice. Always.
Here is my two cents, I've wrote a Zend Framework 1.x resource for Doctrine 2.0
The source code is available on github.
This is another sample about zf1 and D2
https://github.com/marsbomber/zf1-doctrine2/tree/modular_setup
I used it and I think it was useful.