Welcome Guest, Not a member yet? Register   Sign In
Query Caching or NOT?!!!
#5

In CI3 I don't use the built-in query caching. Within code I prefer manually to gain speed in exchange of memory. If a query has a big chance to be put within a cycle, then I store its results within a hidden static variable.

Code:
// Model Enums

    public function get_country_name($id) {

        static $cache = array();

        $id = (int) $id;

        if (array_key_exists($id, $cache)) {
            return $cache[$id];
        }

        $cache[$id] = $this
            ->select("reading")
            ->where('type', CONST_ENUM_NATIONALITY)
            ->as_value()
            ->get($id);

        return $cache[$id];
    }
Reply


Messages In This Thread
Query Caching or NOT?!!! - by pb.sajjad - 06-21-2017, 06:13 AM
RE: Query Caching or NOT?!!! - by rtenny - 06-23-2017, 08:01 AM
RE: Query Caching or NOT?!!! - by natanfelles - 06-23-2017, 08:13 AM
RE: Query Caching or NOT?!!! - by kilishan - 06-23-2017, 09:15 AM
RE: Query Caching or NOT?!!! - by ivantcholakov - 06-24-2017, 11:07 AM
RE: Query Caching or NOT?!!! - by spjonez - 06-26-2017, 12:51 PM



Theme © iAndrew 2016 - Forum software by © MyBB