MDL-41106 Cleaning up expired elements in session cache store

- Always make sure the elements in cache are sorted so we need to remove only elements in the beginning of array
- Remove expired elements from session store to free memory
- Minor bug fixes

Conflicts:
	cache/stores/session/lib.php
	cache/stores/session/tests/session_test.php
MDL-41106 cache: tidied up several elements

Conflicts:
	cache/stores/session/lib.php