Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Joe Price 4 posts 24 karma points
    Feb 23, 2016 @ 07:56
    Joe Price
    0

    UserServer GetPermissions cached results

    When using the UserService and updating a users permissions (ReplacePermissions) for a single node, I use the GetPermissions after performing a replace permissions function I get in the original permissions.

    However these permissions did change correctly. If I recycle the AppPool, clearing the server cache the GetPermissions returns the expected result.

    This is using umbraco 7.4.1, I am unsure if this is on all version 7.

  • brock boyd 2 posts 73 karma points
    Mar 15, 2016 @ 18:00
    brock boyd
    0

    I am having the same issue on version 7.2.8. Did you get this working?

    Updated permissions: userService.ReplaceUserPermissions

    Then

    Get permissions: userService.GetPermissions

    The results from GetPermissions after doing the ReplaceUserPermissions are not showing the update. If I look at the user permissions in Umbraco UI it shows the update. The only way I can get the accurate results from GetPermissions is to restart the app pool.

    I also tried umbraco.library.RefreshContent() to bust the cache on this. Did not work.

    How can I ensure that GetPermissions is pulling the updated results without cycling the app pool?

  • John Mc 9 posts 81 karma points
    Apr 27, 2016 @ 11:37
    John Mc
    0

    Same here, has this been resolved?

  • John Mc 9 posts 81 karma points
    Apr 27, 2016 @ 12:13
    John Mc
    0

    So I've been digging through the source code, and this appears to be quite deliberate.

    In the Permissions Repository, where GetPermissions eventually ends up, there is a hardcode cache expiration of 20 minutes.

    So the question is, can we trigger a cache flush? I've found a class called UserPermissionsCacheRefresher, I'm just trying to figure out whether I can play with it or not :)

  • John Mc 9 posts 81 karma points
    Apr 27, 2016 @ 12:23
    John Mc
    2

    So, to rebuild the cache, you just need to add:

    DistributedCache cache = DistributedCache.Instance; cache.RefreshAll(DistributedCache.UserPermissionsCacheRefresherGuid, true);

    where appropriate :) I do mine after I've removed the permissions :)

  • brock boyd 2 posts 73 karma points
    Apr 27, 2016 @ 16:17
    brock boyd
    1

    That worked!

    Big thanks.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies