UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = '81PoO8BE31huYBEktLOff5jjffCaxeeY5INzbX+2sX0=' 
WHERE 
  key_id = '1736cac6034ef674dca7ef3097d9ad01003d05504a19f15cbadf08b396b544f3' 
  AND (
    token = '81PoO8BE31huYBEktLOff5jjffCaxeeY5INzbX+2sX0=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00032